如何禁用实体框架4.3模式的兼容性检查?兼容性、实体、框架、模式

由网友(嘴贱欠吻)分享简介:我正在与EF 4.3,有一个背景下,需要去跟这是由另一个库使用EF code首先4.3生成的数据库。上下文抛出一个异常,说明I'm working with EF 4.3 and have a context which needs to talk to a database which was generated...

我正在与EF 4.3,有一个背景下,需要去跟这是由另一个库使用EF code首先4.3生成的数据库。上下文抛出一个异常,说明

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 exception stating

The model backing the 'Context' context has changed since the
database was created. Consider using Code First Migrations to update 
the database

在EF 4.1这可以从模型构建器中删除 IncludeMetadataConvention diabled。然而,在4.3这个惯例一直是德precated,不再有效果。

In EF 4.1 this could be diabled by removing the IncludeMetadataConvention from the ModelBuilder. However, in 4.3 this convention has been deprecated and no longer has an effect.

我怎么能有一个EF 4.3上下文交谈EF 4.3生成的数据库中的建立由不同背景的?我发现的唯一的选择(这是非常不理想)是删除元数据表,从而导致的两个的语境假设数据库不是由EF建设。

How can I have an EF 4.3 context talk to an EF 4.3-generated database built by a different context? The only option I've found (which is far from ideal) is to delete the metadata table, thereby causing both contexts to assume the database was not build by EF.

PS:我知道这种情况很可能会提高人们的为什么的,我需要做的问题;我知道这是很不理想,但请放心,这是一个问题,我需要解决和有限制的选择与横向合作。

PS: I know this scenario is likely to raise questions about why I need to do this; I know it's far from ideal, but rest assured it's a problem I need to solve and have limited options to work with laterally.

推荐答案

初始化设置为将跳过模式兼容性检查。

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

Database.SetInitializer<MyContext>(null);
阅读全文

相关推荐

最新文章