Monday, 27 March 2017

Code first Data Migration EF

In Code First we write the code first (Models) and let migration tools create tables.

From Tools --> Library Package Manager --> Package Manager Console.
Enter command:  Enable-Migrations
This command adds a folder named Migrations and file Configuration.cs in the folder.
The file has Seed method to pre-load the tables with data.

Type command: Add-Migration Initial
update-database
The first command generates code that creates the database and second command executes that code.


No comments:

Post a Comment

Bevereages

Types of Beverages Fermented - yeast reacts with sugar to convert into ethyl alcohol & CO2. 4-14% Wine (red, white & rose), Cider ...