无法将多个多对多关系映射到相同的存储“连接”表 [英] Cannot map multiple many-to-many relationships to the same storage 'join' tables
问题描述
您好
我有一个使用TPH的表来提供多种实体类型。我还有一个包含两列的连接表,它们都是另一个表的外键。我正在使用这个连接表来实现我的一个实体上的多对多关系,它工作正常。
但是,如果我将它用于另一个多对多关系中实体(既不是第一个实体的子类或超类的实体),我得到一个警告:'两个可能具有不同键的实体被映射到同一行'。
我不知道我在做什么是一个问题 - 我只是想知道是否有一个解决方法(没有第二个连接表)。
谢谢
Lee
Hello Lee,
您的意思是将链接表映射两次以用于不同的多对多rel ationship?
我不认为EF支持它。 是否可以将其映射到TPH继承图的基本实体上,以便在所有派生实体上设置多对多关联?   
度过美好的一天!
最诚挚的问候,b
Lingzhi Sun
MSDN订阅者支持
在论坛
如果您对我们的支持有任何反馈,请联系
msdnmg@microsoft.com
Hi
I have a table that uses TPH to provide multiple entity types. I also have a join table with two columns, both as foreign keys to the other table. I am using this join table for many-to-many relationships on one of my entities and it works OK.
However, if I use it for another many-to-many relationship in another entity (an entity that is neither a sub- or super-class of the first entity), I get a warning that 'two entities with possibly different keys are mapped to the same row'.
I don't see what I am doing is a problem - i just wondering if there is a workaround (short of having a second join table).
Thanks
Lee
Hello Lee,
Do you mean map the linked table twice for different many-to-many relationship? I don’t think it is supported in EF. Can you map it on the base entity of the TPH inheritance graph so that the many-to-many association will set on all the derived entities?
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
这篇关于无法将多个多对多关系映射到相同的存储“连接”表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!