简体   繁体   English

如何使用Fluent NHibernate自动映射为特定的抽象基类禁用子类

[英]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.

相关问题 流利的NHibernate如何覆盖抽象基类的映射 - Fluent NHibernate how to override mappings for an abstract base class 如何使用Fluent NHibernate自动映射在TPH中的一对多中使用抽象基类? - How can I use my abstract base class in a One to Many in a TPH using Fluent NHibernate automapping? 流利的NHibernate自动将2类映射到一个实体 - Fluent NHibernate auto mapping 2 class to one entity 流利的NHibernate不会在基类中自动映射一对多属性 - Fluent NHibernate not auto-mapping one-to-many property in base class 流畅的NHibernate:如何告诉它不要映射基类 - Fluent NHibernate: How to tell it not to map a base class NHibernate映射与类层次结构,其基类是抽象的,鉴别器不是字符串 - NHibernate mapping with a class hierarchy whose base class is abstract and the discriminator is not a string 如何使用NHibernate 2和Fluent映射和别名进行子选择 - How to Subselect using NHibernate 2 and Fluent mapping with alias 流利的NHibernate,多个抽象基类继承未加载中间基类 - Fluent NHibernate, multiple abstract base class inheritance not loading middle base class 流利的NHibernate类映射和条件 - Fluent NHibernate class mapping with a condition 流利的NHibernate:基类的ISet - Fluent NHibernate: ISet of base class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM