EF Code First Migrations Database migration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.