NHIbernate中无法加载映射文件
我的代码如下:
Configuration cfg = new Configuration();//sessionFactory加载正常
cfg.AddXmlFile("Customer.hbm.xml");//就是这句话报错了
sf = cfg.BuildSessionFactory();
我的映射文件 Customer.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="WebApplication1.MODEL" assembly="WebApplication1">
<class name="Customer" table="Customer">
<id name="Id" type="Int32">
<column name="Id" not-null="true"/>
<generator class="native" />
</id>
<property name="Name" column="c_Name" type="string" length="64" not-null="true" unique="true"></property>
<property name="Address" column="c_address" type="string" length="64" not-null="true"></property>
<property name="Sex" column="c_sex" type="Int32" not-null="true"></property>
</class>
</hibernate-mapping>
Vs 中报的错是:Could not compile the mapping document: Customer.hbm.xml。
网页中报的错是:未能找到文件“C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\Customer.hbm.xml”。