views:

372

answers:

1

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.

A: 

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)));
James Gregory
Thanks for that James. I had wondered what the distinction between that convention and the 'Where' method was, now I know!
Martin MacPherson