views:

72

answers:

1

Why don't I have any class mappings after calling Configuration.Configure()?


WTF

Here is my class mapping file Category.hbm.xml for BudgetModel.Category:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="BudgetModel" namespace="BudgetModel">
  <class name="Category" table="Categories">
    <id name="Id" type="Int32">
      <generator class="native" />
    </id>
    <property name="Name" type="string" not-null="true" />
  </class>
</hibernate-mapping>

EDIT

NH version is 2.1.1.GA

Category.hbm.xml is an embedded resource & I have rebuilt.

+1  A: 

You need to tell NHibernate where your mapping files are. You normally do this either programmatically or in the configuration file.

config.AddAssembly(typeof(Category).Assembly);

or

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <!--Configuration Properties-->
    <mapping assembly="BudgetModel" />    
  </session-factory>
</hibernate-configuration>

Also, your hibernate mapping file must be set with a build action of embedded resource.

Ben Shepheard