Tuesday, March 21, 2017

Migrate code first solution - Entity Framework

Fire up package manager console
























Type Enable-Migrations









A Migration folder will get created in your solution


Do the code changes you need to do for the entities. In my case I have added a new property as BirthDate to my Student class

Then in the Package Manager Window, type Add-Migration with a custom name which you would like to be referred to on the solution. In the solution explorer window, you would see a new file which has been created now.



Then run the update command to update the DB like below. Your changes will get reflected in the Database




No comments:

Post a Comment