The model backing the 'ApplicationDbContext' context has changed since the database was created
Just in case anyone else stumbles upon this that was doing a database first implementation like me.
I made a change by extending the ApplicationUser
class, adding a new field to the AspNetUsers
table, and then had this error on startup.
I was able to resolve this by deleting the record created in the __MigrationHistory
table (there was only one record there) I assume EF decided that I needed to update my database using the migration tool - but I had already done this manually myself.
This worked for me - no other changes required.
DELETE FROM [dbo].[__MigrationHistory]
This post fixed my issue. It's all about adding the following line in Application_Start()
in Global.asax
:
Database.SetInitializer<Models.YourDbContext>(null);
However it cause database recreation for every edit in your model and you may loose your data.