C# 没有类错误的持久化程序
当我运行应用程序时,我得到“Test.Student没有持久器”错误 我是Nhibernate映射的新手,我无法理解这一点C# 没有类错误的持久化程序,c#,asp.net,nhibernate,C#,Asp.net,Nhibernate,当我运行应用程序时,我得到“Test.Student没有持久器”错误 我是Nhibernate映射的新手,我无法理解这一点 我怎样才能解决??plz帮助 NHibernate配置部件 App.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="hibernate-configuration" type="
我怎样才能解决??plz帮助 NHibernate配置部件 App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=(local);database=Student;Integrated Security=SSPI;
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2005Dialect
</property>
<!--<property name="proxyfactory.factory_class">
NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernates
</property>-->
<property name="show_sql">
false
</property>
</session-factory>
}
映射部分
Student.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="Test.Student" table="Info" lazy="true">
<id name="Id" type="int" column="Id">
<generator class="native" />
</id>
<property name="Fname" column ="Fname"/>
<property name="Lname" column="Lname"/>
<property name="Address" column="Address"/>
<property name="Institution" column="Institution"/>
<!-- We don't have to specify a column name if its the same
as the variable name -->
您需要在
app.config
文件中添加映射程序集名称,如上所述
false
如果没有,请确保将XML文件标记为
嵌入式资源
。是否将XML文件生成操作设置为嵌入式资源
?是的,但没有任何区别
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="Test.Student" table="Info" lazy="true">
<id name="Id" type="int" column="Id">
<generator class="native" />
</id>
<property name="Fname" column ="Fname"/>
<property name="Lname" column="Lname"/>
<property name="Address" column="Address"/>
<property name="Institution" column="Institution"/>
<!-- We don't have to specify a column name if its the same
as the variable name -->
<property name="show_sql">false</property>
<mapping assembly="Test"/> <!-- Here -->
</session-factory>