Question

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?

Was it helpful?

Solution

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>());

OTHER TIPS

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

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top