First, manual migration
1th step, enable database migration
Open the Package Manager console
Package Manager, Tools---Library Package Manager console
After opening the console, in the Console Management window, enter the enable-migrations directive, the ammonium key down, to which the database migration has been enabled, but has not yet been executed, the results such as:
2nd step, run the database migration
In the Console Management window, enter the add-migration directive to add a database migration version that must be entered with a version name Add-migration Addproductcategorytypename, such as:
Once run, a new class is added to the Migrations folder in the solution, 201407030630269_addproductcategorytypename.cs
The 3rd step, formally to the database migration action, in the Controller window input update-database instructions can be executed, such as:
Second, automatic migration
1. Add a piece of code to the Application_Start () method inside the Global.asax class
2. Open in Migrations/configuration.cs class
Automaticmigrationsenabled = true;
3, every update must be executed in the window database migration Instructions Update-database
Third, automatic migration is not applied because automatic migration can lead to data loss resolution
Just run the add-migration Initial command in the console window and enter Update-database to perform the update.