DbMigrator Update() issue after updating to EF 6.2
See original GitHub issueI have been getting the following issue after updating my project from EF 6.1.3 to 6.2. This is an Asp.Net application where I keep my Code First models and Db context in a separate project.
Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
Following is the code where I get the exception, which is in Startup.Auth.cs file.
// Entity Framework Db Migration
var efMigrationSettings = new Domain.Services.Migrations.Configuration();
var efMigrator = new DbMigrator(efMigrationSettings);
efMigrator.Update();
I do not get any error when I tried manually updating the db from the “Package Manager Console” using “update-database” command, and yet when I run the app using F5 I still get this error.
But when I downgraded EF to 6.1.3 everything started working perfectly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Many thanks to @mark-trumed for commenting. I was in the exact same situation.
I had this problem maybe it’s too late to report here, my code:
the exception say:
if I change the
AutomaticMigrationsEnabled
totrue
, the exception say:at last, if I do the
EntityFramework\Add-Migration test
in visual studio 2019 Package Manager Console, it always generate an empty migration record that means the Model and the migration history is aligned.BTW, the above
Netwonsoft.Json 11.0.2
explain is not my situation, I had its version of 12.