实体框架CTP5不能检查模型兼容性,因为数据库不包含模型元数据 [英] Entity framework CTP5 Model compatibility cannot be checked because the database does not contain model metadata
本文介绍了实体框架CTP5不能检查模型兼容性,因为数据库不包含模型元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用现有的表格测试Entity Framework CTP 5 Code First。
- 我定义了模型类和DbContext并运行了应用程序。它创建了数据库和表。
- 我从数据库中删除了
EdmMetadata
表。 - 在我的连接字符串中添加了
Trusted_Connection = true; Persist Security Info = True
。 - 当我再次运行应用程序时,它给了我错误
System.NotSupportedException未被用户代码处理
Message =模型兼容性无法检查,因为数据库不包含
包含模型元数据。
Source = EntityFramework
如何使此应用程序在没有 EdmMetadata
表的情况下运行
解决方案
$ _ code> protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove& IncludeMetadataConvention>();
}
如果您不想使用EdmMetadata表,请尝试将其添加到您的 DbContext
派生类中:
$ _ code> protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove& IncludeMetadataConvention>();
}
I am trying to test the Entity Framework CTP 5 Code First with an existing table.
- I defined the model class and DbContext and ran the application. It created the database and table.
- I dropped
EdmMetadata
table from the database. - Added
Trusted_Connection=true;Persist Security Info=True
in my connection string. - When I run the application again, it gives me this error.
System.NotSupportedException was unhandled by user code
Message=Model compatibility cannot be checked because the database does not contain model metadata.
Source=EntityFramework
How can I make this application run without EdmMetadata
table?
解决方案
If you don't want to use EdmMetadata table try to add this into your DbContext
derived class:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
}
这篇关于实体框架CTP5不能检查模型兼容性,因为数据库不包含模型元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文