EF CTP5中的modelBuilder.IncludeMetadataInDatabase在哪里? [英] Where is modelBuilder.IncludeMetadataInDatabase in EF CTP5?

查看:179
本文介绍了EF CTP5中的modelBuilder.IncludeMetadataInDatabase在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CTP4,我以前可以执行以下操作(如由ptrandem建议):

With CTP4, I used to be able to do the following (as suggested by ptrandem):

modelBuilder.IncludeMetadataInDatabase = false

使用这一行代码,EF不会在我的数据库中创建EdmMetadata表,

With this line of code, EF doesn't create the EdmMetadata table in my database, and doesn't track model changes.

在新的CTP5中,我无法找到一种方法来完成此任务,所以现在每次更改模型时,我都会得到以下结果: / p>

I was unable to find a way to accomplish this in the new CTP5, so now every time I change my model, I get this:


自创建数据库
以来,支持MyContext
上下文的模型已更改。或者手动
删除/更新数据库,或者使用
IDatabaseInitializer实例调用
Database.SetInitializer。对于
示例,
DropCreateDatabaseIfModelChanges
策略将自动删除,
重新创建数据库,并且可选地
将其与新数据进行种子。

The model backing the 'MyContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

那么大家知道CTP5中的IncludeMetadataInDatabase属性在哪里?谢谢。

So, does everybody know where is the IncludeMetadataInDatabase property in CTP5? Thanks.

推荐答案

CTP5包含一个非常酷的功能,称为可插拔约定,可用于添加/删除约定。 IncludeMetadataInDatabase 已被删除,并被替换为

可插拔约定,为您做同样的事情:

CTP5 includes a very cool feature called Pluggable Conventions that can be used to Add/Remove conventions. IncludeMetadataInDatabase has been removed and being replaced with a
pluggable convention that does the same thing for you:

modelBuilder.Conventions
            .Remove<System.Data.Entity.Database.IncludeMetadataConvention>();

这篇关于EF CTP5中的modelBuilder.IncludeMetadataInDatabase在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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