How to disable migration in Entity Framework 4.3.1?

前端 未结 3 700
一向
一向 2020-12-01 10:23

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 wo

相关标签:
3条回答
  • 2020-12-01 10:57

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

    0 讨论(0)
  • 2020-12-01 11:08

    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>());
    
    0 讨论(0)
  • 2020-12-01 11:12

    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)

    0 讨论(0)
提交回复
热议问题