1>, in the Package Manager console, execute the statement:
Pm> enable-migrations-enableautomaticmigrations
After execution succeeds, add the Migrations folder to the application code structure, and generate the class file Configuration.cs.
2>, in the Package Manager console, execute the statement:
Pm> add-migration Initialcreate
After successful execution, new class files are added in the Migrations folder month and day seconds _initialcreate.cs
3>, in the Package Manager console, execute the statement:
Pm> Update-database-verbose
Execution results generate a database consistent with the above
4>, add the model class in the database model, execute the Package Manager console statement, migrations the new class file in the folder month Day time _model class. cs.
Pm> Add-migration Model Class
Execute the Package Manager console statement again
Pm> Update-database-verbose
Version backtracking
Modify the table for the table model class in the database. Execute the following two statements in the Package Manager console:
Pm> add-migration modifycity
Pm> Update-database-verbose
After successful execution, the model table structure modifies the
Executes the Package Manager console statement for database version backtracking.
Pm> update-database–targetmigration: To the CS file under the Migrations folder
EF Code First Migrations Database migration