When trying to run my ASP.NET MVC application locally, everything works fine. But once I've deployed it Azure, it keeps giving me the error:
Unable to update database to match the current model because there are pending changes and automatic migration is disabled.
So I connected to the remote database using the Package Manager Console in Visual Studio and ran the Update-Database command. This gave me the same error. When I look at the database inside the SQL Server Management Studio, it looks like all migrations are applied.
So after this I tried running Add-Migration to see if there were any changes I didn't notice. The migration it created was exactly the same as the previous two migration (there is nothing in there that's not in one of those migrations).
So far the site ran just fine for about two weeks, including a few migrations. I'm at a loss as to how to solve this, so any help is appreciated.
I'm certain I'm connecting to the right database, because I see it change when I update it to a target migration. I'm also targeting the correct project.
If you are sure that the
Add-Migration is creating the script for changes that are already applied, you need to update the migration state of your database. You can do this by adding an empty migration. This will capture the state of your current model.
Add-Migration MergeChanges â€“IgnoreChanges
After running this command you will have an empty migration script. Now you can update your database to match the model state. Since the actual migration doesnâ€™t contain any changes, it will simply add a row to the __MigrationsHistory table indicating that this migration has already been applied.
NOTE Run this only if you do not have any pending changes and yet you see the error message to update the database.
Probably you have 2 ore more DbSet<> with the same "name" into you Model/IdentityModels.cs generated itself while updating database through Package Manager Console. Try to keep only the one you want. Hope it helps