我added a new ADO.Net Entity Data Model进入我的项目并使用 Update Wizard将表添加到模型中。五个选定的表格已添加到设计图面上。另外两个表不会添加。我在向导中选择它们并单击“完成”,但它们从未显示在设计界面上。
这是一个错误,还是在某些情况下无法将表添加到模型(按设计)?
<小时/>更新:XML (*.edmx) 揭示了问题。
<!--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>-->
最佳答案
设计图面与实体模型不同。 EDMX 中的映射中可能有一个表不会出现在设计图面上。查看 XML 格式的文件,看看情况是否如此。在这种情况下,更新向导将不允许您重新添加表,因为它们已经是实体模型的一部分。因此,一般来说,更新向导对实体模型的了解比对设计界面的了解更多,本身。
我认为这并不完全是您所处的情况,但它应该为您提供解决方案的总体思路:进入 XML 并查找对相关表的引用。
关于.net - ADO.NET Entity Framework : Update Wizard will not add tables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/543971/