EDMX 循环导航
我们确定,如果您有两个相关的实体,然后保留它们之间的默认导航属性(一个指向另一个并返回),则无法保存实体数据。只能保留一个导航属性。
例如:
ENTITY:USER
Property.UserId
NavigationProperty.Favorites
_
ENTITY:FAVORITE
Property.FavoriteId
Property.URL
Property.UserFk
NavigationProperty.Users
有人知道检测这些循环导航属性的简单方法吗?我知道一种方法是手动查找它们 - 我们正在这样做,但是我们的数据库中有数百个实体事实证明,EDMX 和“手动”方法并不是一个可靠的选择。
谢谢。
We have determined that if you have two entities that are related and then you leave the default navigation properties between them (one pointing to the other and back), then saving Entity data is not possible. Only one navigation property can be kept.
For example:
ENTITY:USER
Property.UserId
NavigationProperty.Favorites
_
ENTITY:FAVORITE
Property.FavoriteId
Property.URL
Property.UserFk
NavigationProperty.Users
Does anyone know of an easy way to detect these circular navigation properties? I know one way is to look for them by hand - we're doing that, but we have hundreds of entities in our EDMX and "manual" approach is proving to not be a realiable option.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定它是错误的 - 保存实体没有任何问题。导致问题的唯一情况是序列化,可以使用 其他元数据。
You have determined it wrong - saving entities works without any problem. The only scenario where this cause problems is serialization where it can be solved for some serializers with additional metadata.