[英]How to disable subclassing for a specific abstract base class using Fluent NHibernate auto mapping
I have an abstract base class that I'm referencing from one of my entities. 我有一个从我的实体之一引用的抽象基类。 This caused the following exception when generating the schema:
生成架构时,这导致以下异常:
An association from the table Audits refers to an unmapped class: Entity
表Audits中的关联是指未映射的类:实体
Therefore, I had to include that base class in the auto persistence model: 因此,我必须在自动持久性模型中包括该基类:
autoPersistenceModel.IncludeBase<Entity>()
Now, my current problem is that Fluent NHibernate creates a huge mapping for the base class, providing a joined-subclass
for each entity. 现在,我当前的问题是Fluent NHibernate为基类创建了一个巨大的映射,为每个实体提供了一个
joined-subclass
。 This is of course not what I want. 这当然不是我想要的。
So, the question is: how do I setup the auto mapping override of in such a way that it doesn't perform any subclassing? 因此,问题是:如何以不执行任何子类化的方式设置其自动映射覆盖?
The AutoMapping<Entity>
type only seems to provide means of choosing a subclassing strategy but no way of disabling it. AutoMapping<Entity>
类型似乎仅提供选择子分类策略的方法,而没有禁用它的方法。
After giving this some thought, I realized that I could define a custom mapping, as simple as this: 考虑了一下之后,我意识到我可以定义一个自定义映射,就像这样简单:
public class EntityMap : ClassMap<Entity>
{
public EntityMap()
{
Id(n => n.Id);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.