ef codeFirst modify table structure such as adding a field EF code first need to rebuild the library cause data loss problems.

We need to run the following command in the library in the package manager:

1. Enable migration: the Enable--ContextTypeName MvcMovie.Models.MovieDbContext, Migrations, 
2. establish initial state: the Add-Migration the Initial 
3. Migration automatically generated based on the ratio of the difference: the Add-Migration AddRatingMig 
4. Migrate to the database: update- database
Migrations-order execution the Enable 
 the Add-Migration 1 (1 is just written) 

 Update-Database

Guess you like

Origin www.cnblogs.com/llsg/p/11520712.html