How can I disable migration in Entity Framework 6.0

后端 未结 7 1560
傲寒
傲寒 2020-11-29 01:24

I\'m trying to ignore the \"Automatic\" migration using Entity Framework 6.0 rc1. My problem is that I don\'t want this feature right now and every time that my application

7条回答
  •  臣服心动
    2020-11-29 01:57

    Try this, Add this line in your MyContext class, this will be called before your MyContext constructor is called. This will stop creating the database as well as won't add tables into a connected database. Basically this line disables the default Code-First Database Initialization strategy which basically has a default strategy as CreateDatabaseIfNotExists.

    static MyContext()
    {
           System.Data.Entity.Database.SetInitializer(null);
    }
    

提交回复
热议问题