Asp.net-mvc – Model backing a DB Context has changed; Consider Code First Migrations

asp.net-mvcentity-framework

The model backing the 'MyDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

What causes this to happen? I've literally just created a brand new database and have changed nothing, but every time I try to access a model from a controller it throws this.

Edit

It has something to do with the fact that I was attempting to share a connection string (i.e. a database) with two separate entities.

Best Answer

In my case this error was caused by the existence of the _MigrationsHistory table in the database. Deleting that table fixed the problem. Not sure how that table got into our test environment database.

Related Topic