ADO.NET实体框架:更新向导不会添加表 [英] ADO.NET Entity Framework: Update Wizard will not add tables

查看:206
本文介绍了ADO.NET实体框架:更新向导不会添加表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中添加了一个新的ADO.Net实体数据模型,并使用更新向导将表格添加到模型中。将五个选定的表添加到设计表面。另外两个表不会添加。我在向导中选择它们,然后单击完成,但它们从未出现在设计面上。

I added a new ADO.Net Entity Data Model into my project and used the Update Wizard to add tables into the model. Five of the selected tables were added to the design surface. Two other tables will not add. I select them in the wizard and click Finish, yet they never show up on the design surface.

这是一个错误,还是有些情况下,表不能添加到模型(按设计)?

Is this a bug, or are there some situations where a table cannot be added to the model (by design)?

更新:XML(* .edmx)显示了问题。

UPDATE: The XML (*.edmx) reveals the problem.

<!--Errors Found During Generation:
warning 6013: The table/view 'FooBar.dbo.Roles' does not 
have a primary key defined and no valid primary key could be inferred. 
This table/view has been excluded. To use the entity you will need to 
review your schema, add the correct keys and uncomment it.-->
<!--<EntityType Name="Roles">
    <Property Name="role_id" Type="decimal" />
    <Property Name="role_desc" Type="nvarchar" MaxLength="30" />
</EntityType>-->

感谢 Craig 为您的回应。

推荐答案

设计面与实体模型不同。您可以在EDMX中的映射表中设置表格。以XML格式查看文件,看是否是这样。在这种情况下,更新向导将不允许您重新添加表,因为它们已经是实体模型的一部分。因此,一般来说,更新向导比您的实体模型更了解您的实体模型。

The design surface is different from the entity model. It is possible to have a table in the mapping in your EDMX which does not appear on the design surface. View the file as XML to see if this is the case. In this case, the Update Wizard will not allow you to re-add the tables, since they are already part of the entity model. So, generally speaking, the Update Wizard knows more about your entity model than it does about the design surface, per se.

我不t认为这正是您所处的情况,但它应该为您提供解决方案的一般想法:进入XML并查找有关表的引用。

I don't think that's exactly the situation you're in, but it should give you the general idea for the solution: go into the XML and look for references to the tables in question.

这篇关于ADO.NET实体框架:更新向导不会添加表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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