EF6 Code Migrations - Database is different, but nonetheless
Sorry to post such a general question, but it may have multiple answers for multiple situations (and I might have to recreate the db before I can get an answer), so here it is:
We have a C # project using EF6 that has been using EF Migrations successfully for several months. This morning when I try to start my project, I get this all too familiar error:
System.Data.Entity.Migrations.Infrastructure.AutomaticMigrationsDisabledException 'occurred in EntityFramework.dll but was not handled in user code
Additional information: The database cannot be updated to match the current model because there are pending changes and automatic migration is disabled. Either write pending model changes to a code-based migration or enable automatic migrations. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
Except that I cannot find any evidence that anything has changed.
- The __MigrationHistory database corresponds to the Migrations in the project.
- If I do add-wrap, empty Up and Down methods appear in it.
- We restored the database from a few nights ago (when we know it worked) to a temporary database and did a comparison and no structural changes were found.
- I even tried running "update-database" on a blank migration, which worked, but the error still occurs.
Any ideas on how this scenario might come about?
source to share
We found the problem. The main project in our solution was upgraded from EF 6.0.2 to EF 6.1.1, but the MVC project was not.
This did not cause problems when it was originally done a few days ago. But yesterday a team member created the first migration with a new version (just added data, no structural changes). Once this migration was over, the MVC project could no longer interact with the db.
What finally put us off was seeing a new ProductVersion in the __MigrationHistory table.
As soon as I updated the MVC project the problem was resolved.
Thanks to those who offered suggestions. Hopefully, if anyone else has the same symptom, they can find the answer among these posts.
source to share