amiry jd
amiry jd

Reputation: 27585

How to disable migration in Entity Framework 4.3.1?

Is there any way to disable migration in Entity Framework 4.3.1? I removed the migrations folder from the project and the generated tables in my database, but it doesn't work! How can you remove the migration?

Upvotes: 39

Views: 61334

Answers (3)

Buzzrick
Buzzrick

Reputation: 833

The way that I got around this was to make sure that I turned off Automatic Migrations in my code:

internal sealed class Configuration : DbMigrationsConfiguration<YourContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
    }
}

and then I deleted the _MigrationHistory table from the database (this is usually created as a system table if you can't find it)

Upvotes: 4

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364249

If you don't want to use migrations but in the same time you want EF to create database for you, you just need to set correct database initializer:

Database.SetInitializer<YourContextType>(new CreateDatabaseIfNotExists<YourContentType>());

Upvotes: 40

Noel
Noel

Reputation: 2120

Deleting the Migrations folder has worked for me. I don't get any errors, it puts me back to where I started.

Upvotes: 35

Related Questions