[英]Same table relationship in Entity Framework
Is it possible to have an association mapping a table to itself? 是否可以将表格映射到自身?
eg 例如
Table:
ConditionId
ConditionName
...
...
ParentConditionId
where we can have many ParentConditionIds each mapping to the same ConditionId. 我们可以在其中有许多ParentConditionIds,每个映射到相同的ConditionId。
I've tried a one to many mapping but I'm getting an error when there is no children. 我尝试了一对多的映射,但是在没有孩子时我遇到了错误。
Yes it is possible. 对的,这是可能的。 Put the FK in your database and the wizard will map it correctly.
将FK放入数据库,向导将正确映射它。 Make sure ParentConditionId is nullable.
确保ParentConditionId可以为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.