我似乎无法让我的 nHibernate 测试项目运行,我正在使用以下配置文件和代码:
country.hbm.xml 标记为嵌入资源:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="SVL.Models.CountryModel, SVL" table="country">
<id name="Id" type="int" />
<property name="Name" type="String" length="200" />
</class>
</hibernate-mapping>
我的休眠配置文件:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<!-- properties -->
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.MySqlDataDriver
</property>
<property name="connection.connection_string">
Server=localhost;Database=svl;User ID=root;Password=pfje1008;
</property>
<property name="dialect">
NHibernate.Dialect.MySQL5Dialect
</property>
<mapping resource="country.hbm.xml" assembly="SVL" />
</session-factory>
</hibernate-configuration>`
最后是设置休眠配置的代码:
var cfg = new Configuration();
cfg.Configure();
var sessionFactory = cfg.BuildSessionFactory();
var thisAssembly = typeof(T).Assembly;
cfg.AddAssembly(thisAssembly);
由于某种原因,它一直告诉我找不到资源文件...