我使用added a new ADO.Net Entity Data Model进入我的项目并使用Update Wizard将表添加到模型中。所选表中的五个已添加到设计图面。另外两个表将不会添加。我在向导中选择它们并单击Finish,但它们从未出现在设计图面上。
这是一个bug吗?或者在某些情况下,表不能被添加到模型中(根据设计)?
更新: 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>-->
发布于 2010-07-21 19:37:08
将主键设置为所有表,或者只将一个未选中的复选框"Allow null“设置为每个表的任何列。它适用于我:)
发布于 2017-03-02 04:58:27
检查特定表中的“Nulls”。如果所有列都设置为“Allow Null”,则Entity Framework将其视为“Null”表。我也有同样的问题,没有勾选'Allow Null‘,它就添加了所需的表。
发布于 2019-04-05 19:48:35
不会添加没有主键的表。
https://stackoverflow.com/questions/543971
复制相似问题