NHibernate MappingException an association from the table refers to an unmapped class

When you are creating your mapping files for which NHibernate uses to know the data types and relationships of the data model, you are likely to receive this error message:

An association from the table TABLENAME refers to an unmapped class: CLASS

image

The is usually generated from the class.hbm.xml file within a many-to-one mapping where you have included the class attribute with a value equal to the class.

It is resolved by either adding the namespace where the class exists or removing the class attribute all together as it is an optional setting.

Simply change this:

<many-to-one name="NAME" class="CLASS" column="THE_ID" /> 

To:

<many-to-one name="NAME" class="NAMESPACE.CLASS" column="THE_ID" />