Fluent NHibernate 自动映射中的自引用多对多关系
标题几乎解释了这一切,我有一个成员对象,它引用也是成员类型的“朋友”。
public class Member : Entity
{
public Member()
{
Friends = new List<Member>();
}
public virtual IList<Member> Friends
{
get; set;
}
}
模式生成工具使其成为 1:n 关系,而它应该是 an:n 关系,即向名为 member_id 的成员表添加一列,并且不创建连接表。
有什么方法可以在 Fluent NHibernate 中创建 Self 引用多对多关系吗?
The title pretty much explains it all, I have a Member object that references 'Friends' who are also type Member.
public class Member : Entity
{
public Member()
{
Friends = new List<Member>();
}
public virtual IList<Member> Friends
{
get; set;
}
}
The schema generation tool makes it a 1:n relationship while it should be a n:n relationship i.e. a column is added to the member table called member_id and no connecting table is created.
Is there any way to make a Self referencing many to many relationships in Fluent NHibernate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
绝对有可能。您只需要创建一个覆盖,
只需告诉自动映射配置您的覆盖将包含这些内容。
编辑:更新为包括父键和子键列
Definitely possible. You just need to create an override
Just tell the auto mapping configuration where your overrides are to have these included.
EDIT: Updated to include Parent and Child key columns