Mark
Mark

Reputation: 23

Entity Framework Change Assembly Model not recognised

I have an MVC 5 website with using the entity framework V6.1.1. The entity framework DbContext classes and models were originally all inside the website project. This project had 3 DbContext classes and 3 databases. I had also enabled migrations and applied one one of these databases.

I have now moved all the entity framework classes including the models and the migrations to a separate project and since then I have been getting the following error for the databases where a migration has been applied:

The model backing the 'MyContext' context has changed since the database was created.

The database has not changed. I have also made sure the Context Key is the same in both the Configuration constructor and the database __MigrationHistory table.

I have also been seeing the following behavior:

I have also been looking through all the migrations files including the designer files and the namespaces all match up. If anyone could shed some light on this problem it would be much appreciated.

Upvotes: 2

Views: 69

Answers (1)

Dylan Slabbinck
Dylan Slabbinck

Reputation: 854

You should put this in the constructor of 'MyContext'

> Database.SetInitializer<YourDbContext>(null);

Upvotes: 0

Related Questions