Reputation: 1842
I have a C# solution. Recently, we moved the solution into a new repository.
In the OLD solution, I have a soon-to-be deprecated console app that accesses my Azure-hosted DB to do some work. We had some new DB migrations in the new repository and had some work that required the console app, so I moved the app project over into a throwaway branch in the new repo just so I could build it with the latest migrations.
It compiles fine. However, when I try to run it, I ALWAYS get the The model backing the 'DataContext' context has changed
error.
What's weird about this is that my code and my DB are on the same migration. I can even run the update-database
command on that DB and it tells me that I have "no pending migrations". I did compares on the stored procedures in my visual studio and the DB and they are all equal. Same results when trying Add-Migration "SyncTest"
, it creates a migration with no changes.
I cannot delete the __MigrationHistory
table because I need to run this console app on production servers and cannot afford to lose that data/have any downtime.
So if I am on the same migration step between my console app and my DB, then why is it still throwing this error? I dunno where else to check!
Upvotes: 2
Views: 703
Reputation: 3841
I don't know why it is happening in your particular case, but I did stumble across a way to turn off the error, put this line in your DbContext instance ctor:
Database.SetInitializer<YourDbContextClass>(null);
Upvotes: 2