How can I disable model compatibility checking in Entity Framework 4.3?

后端 未结 2 789
再見小時候
再見小時候 2020-11-30 10:37

I\'m working with EF 4.3 and have a context which needs to talk to a database which was generated by another library using EF Code First 4.3. The context is throwing an exc

相关标签:
2条回答
  • 2020-11-30 11:33

    Setting the initializer to null will skip the model compatibility check.

    Database.SetInitializer<MyContext>(null);
    
    0 讨论(0)
  • 2020-11-30 11:38

    For EF 4.3 or higher

    Database.SetInitializer<MLTServerWatcherContext>(null);
    

    Or if using older version of EF

    modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
    

    (I know he said he are using EF 4.3, but i think it's good to show this option too)

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