Code First Data migration

Source: Internet
Author: User

Once the project is online, you need to make changes to the database and no longer use dropcreatedatabaseifmodelchanges

If you manually modify the DbContext or entity class, an error occurs:

Models that support the "entities" context have changed since the database was created. Consider migrating the update database using Code first.

Enter Enable-migrations in the package Manage console to enable the migration feature.

  • add-migration would scaffold the next migration based on changes and made to your model since the last Migrat Ion was created

  • Update-database 'll apply any pending migrations to the Database

Do not enable the migration feature, manually conform to the entity class changes to the database, delete the automatically generated table _mirgration in the database, the error will not be reported. Manually modifying the database is consistent with the changes to the entity class.

Code First Data 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.