Fluent NHibernate Subclassmap 重复父外键
我对 Fluent NHibernate 相当陌生,并且正在尝试使用继承,但我在 NHibernate 创建的数据库模式中得到了意外的结果。希望有人能够阐明或指出我在这个例子中做错了什么:
public class BaseClassMap: ClassMap<BaseClass>
{
BaseClassMap()
{
Id(x => x.Id).GeneratedBy.Identity();
some other fields mapped here
References(x => x.RelatedEntity).Not.Nullable();
}
}
public class ChildClass: BaseClass
{
}
public class ChildClassMap: Subclassmap<ChildClass>
{
ChildClassMap()
{
Map some more fields here
}
}
问题是相关实体的外键同时位于子表和父表中,我想不出我想要的任何原因那。任何帮助将不胜感激。
=============== * 1 ==================== 1 1 ====================
|RelatedEntity|-------- |BaseClass |-----------| ChildClass |
=============== ==================== ====================
| Id | | Id |
| RelatedEntity_id | | RelatedEntity_id |
-------------------- --------------------
I'm fairly new to Fluent NHibernate and am trying to use inheritance but I'm getting unexpected results in the database schema created by NHibernate. Hopefully someone can shed some light or point out what I'm doing wrong this this example:
public class BaseClassMap: ClassMap<BaseClass>
{
BaseClassMap()
{
Id(x => x.Id).GeneratedBy.Identity();
some other fields mapped here
References(x => x.RelatedEntity).Not.Nullable();
}
}
public class ChildClass: BaseClass
{
}
public class ChildClassMap: Subclassmap<ChildClass>
{
ChildClassMap()
{
Map some more fields here
}
}
The problem is the foreign key to the related entity is in both the child and parent tables and I can't think of any reason why I would want that. Any assistance would be greatly appreciated.
=============== * 1 ==================== 1 1 ====================
|RelatedEntity|-------- |BaseClass |-----------| ChildClass |
=============== ==================== ====================
| Id | | Id |
| RelatedEntity_id | | RelatedEntity_id |
-------------------- --------------------
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论