简体   繁体   中英

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

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. 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.

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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM