开发者

NHibernate - No Class Mappings

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

Here is my class mapping file 开发者_如何学PythonCategory.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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜