NHibernate [MappingException:无法编译映射文档:iMed.Models.Device.hbm.xml]
问题描述:
我目前正在尝试使用nhibernate和MVC 3.5。NHibernate [MappingException:无法编译映射文档:iMed.Models.Device.hbm.xml]
我已将我的nhibernate.cfg.xml放入我的根目录中,以便放入我的MVC项目。 请参阅项目的屏幕截图。这两个xml文件都设置为嵌入式资源。
我有一个DeviceRepository.cs它有一个使用Device.cs持久性的方法。
这里是nhibernate.cfg.xml的XML
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=192.168.1.5;Database=imed_development;User ID=root;Password=lights337</property>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<!-- mapping files -->
<mapping resource="iMed.Models.Device.hbm.xml" assembly="iMed" />
这里是Device.hbm.xml
的XML<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="iMed.Models.Device" table="devices">
<id name="Id" column="ID" type="int">
<generator class="native"></generator>
</id>
<property name="Identifier" column="identifier" type="String"></property>
</class>
</hibernate-mapping>
我目前得到一个
{"Could not compile the mapping document: iMed.Models.Device.hbm.xml"}
{"persistent class iMed.Models.Device not found"}
我很新的这一点,任何输入将不胜感激......提前
谢谢...
Patrick
答
它说你在映射中引用了一个不存在的类。