[英]Inserting Multiple Inherited Entities Gives - Unable to determine the principal end of the relationship
I'm using EF5 and I'm having an issue where I can add 1 instance of an inherited entity and save it successfully, but if I add two or more instances of the type, I run into the issue below. 我正在使用EF5,但遇到一个问题,我可以添加1个继承实体的实例并成功保存,但是如果添加两个或多个该类型的实例,则会遇到以下问题。
These entities are inherited types from a base type. 这些实体是从基本类型继承的类型。 FkEssayItemContent is the FK relationship that ties my type,
EssayItem
, to it's base, Content
. FkEssayItemContent是将我的类型
EssayItem
与它的基础Content
绑定的FK关系。
Unable to determine the principal end of the
'TDSModel.FkEssayItemContent' relationship.
Multiple added entities may have the same primary key.
What am I missing here, such that one entity would insert fine, but two of them inserted at once would cause this problem when using inheritance? 我在这里缺少什么,这样一个实体可以很好地插入,但同时插入两个实体会在使用继承时导致此问题?
Thanks! 谢谢!
I ended up answering this myself. 我自己回答了这个问题。 It turns out that in addition to an inheritance relationship, the model had an association between
EssayItem
and `Content'. 事实证明,除了继承关系之外,该模型
EssayItem
和“ Content”之间建立了关联。 Removing that association and maintaining the inheritance fixed the issue. 删除该关联并维护继承可解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.