EF6 with new database generates 'The model backing the <Database> context has changed since the database was created.'

StackOverflow https://stackoverflow.com/questions/22314954

Question

I have been developing a Code First database via migrations for a couple of weeks. I added a few tables yesterday and got the error

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

After trying a couple of things I dropped the database, removed all code migrations, cleaned the solution, added a single migration and ran an Update-Database but I still get the same error.

If I run Add-Migrations again, nothing is generated so something thinks they're the same.

I'm running VS2013. I have two projects, one for the entities and the other for the MVC project. I've read about moving the entities into the main project but that sounds like a backwards solution if I've ever heard one.

What on earth do I do to get this running again?

Était-ce utile?

La solution

A work around is to set the database initializer to null

public class DanceDb : DbContext
{
    public DanceDb() : base("name=DanceEntities")
    {
        Database.SetInitializer<DanceDb>(null);
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top