Entity Framework 6.1.1 disable model compatibility checking

前端 未结 3 1615
一生所求
一生所求 2020-12-24 13:59

I am running into the following error after updating EF to version 6.1.1:

An unhandled exception of type \'System.InvalidOperationException\' occurred

相关标签:
3条回答
  • 2020-12-24 14:20

    You can also set it in Web.config file

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <appSettings>    
        <add key="DatabaseInitializerForType YourNamespace.YourDbContext, AssemblyName"
                value="Disabled" />
        </appSettings>
    </configuration>
    

    Decision from: http://www.entityframeworktutorial.net/code-first/turn-off-database-initialization-in-code-first.aspx

    0 讨论(0)
  • 2020-12-24 14:39

    To expand on Dabblernl's answers:

    public ApplicationDbContext()
            : base("DefaultConnection", throwIfV1Schema: false)
        {
            Database.SetInitializer<ApplicationDbContext>(null);
        }
    
    0 讨论(0)
  • 2020-12-24 14:43

    This should work, put it somewhere in the constructor of your derived DbContext:

    Database.SetInitializer<MyContext>(null);
    
    0 讨论(0)
提交回复
热议问题