R – ‘Table with concrete class’ mapping using Fluent NHibernate’s auto mapping

fluent-nhibernatenhibernate

Does anyone whether it is possible to configure Fluent NHibernate to auto-map objects using 'Table with concrete class' inheritance. On looking at the auto-mappings (which I had written to file) I have a number of entities that derive from EntityBase but I would like the Id column to be on each table rather than on an EntityBase table.

<class name="EntityBase" table="EntityBase" xmlns="urn:nhibernate-mapping-2.2">
    <id name="Id" type="Int32" column="EntityBaseID">
      <generator class="identity" />
    </id>
    <joined-subclass name="CategoryType, ..., Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
      <key column="EntityBaseId" />
      <property name="CategoryTypeGUID">
        <column name="CategoryTypeGUID" />
      </property>
    </joined-subclass>
</class>

I scoured the Fluent docs but can't see anything related to this.

Thanks in advance.

Best Answer

Have you set the IsBaseType convention in your automapping? This particular convention defines what is deemed as simply a base class in your code, rather than something to be considered as part of an entity inheritance hierarchy.

AutoPersistenceModel
  /* regular config */
  .WithSetup(s =>
    s.IsBaseType = (type => type == typeof(EntityBase)));