如何禁用实体框架4.3模式的兼容性检查? [英] How can I disable model compatibility checking in Entity Framework 4.3?

查看:192
本文介绍了如何禁用实体框架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 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);

这篇关于如何禁用实体框架4.3模式的兼容性检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆