After migrating the database using the Entity Framework, the error is corrected every time the code is modified (not the model code).

Source: Internet
Author: User

Issue: After migrating the database using the Entity Framework, each time you modify the code (not the Model code), the error is:

Models that support the "Xxxdbcontext" context have changed since the database was created. Consider migrating the update database (http://go.microsoft.com/fwlink/?LinkId=238269) using Code first.

At this point the migration code generated by the execution of add-migration is empty. So re-update-database, the result is no pending explicit migrations.

However, this is not an error, but every time to modify the code to update-database. Very strange, debugging for a long time did not find out where the problem, so suspect is the Entity framework of the bug, read the source code of the Entity Framework, found that reading does not understand, the level is too limited.

So I looked it up online and there was a solution:

Database.setinitializer<dbcontext> (NULL);

It would be nice to put the above sentence in the Application_Start (), but it feels like it's not a fundamental way to solve the problem.

Finally, accidentally found this article on the StackOverflow, the original is indeed the entity Framework 6.0.0 bug. So the upgrade to 6.1.0, the problem is gone.

Troubled the N-day problem finally solved, the mood is big cool!

Ext.: http://blog.csdn.net/wmzy1067111110/article/details/25333363?reload

After migrating the database using the Entity Framework, the error is corrected every time the code is modified (not the model code).

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.