错误信息
Unable to locate persister for the entity named 'Model.Customer'.
The persister define the persistence strategy for an entity.
Possible causes:
- The mapping for 'Model.Customer' was not added to the NHibernate configuration.
实体映射文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
<class name="Model.Customer,Model" table="Customer">
<id name="CustomerId" column="CustomerId" type="Int32">
<generator class="GuidNative"/>
</id>
<property name="versions" column="versions" type="string"></property>
<property name="firstName" column="firstName" type="string"></property>
<property name="lastName" column="lastName" type="string"></property>
</class>
</hibernate-mapping>
数据库配置文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">
Data Source=.;Initial Catalog=NHibernateSample;Persist Security Info=True;User ID=sa;pwd=sasa</property>
<property name="proxyfactory.factory_class">NHibernate.Bytecode.DefaultProxyFactoryFactory,NHibernate</property>
<property name="show_sql">true</property>
<property name="command_timeout">10</property>
<property name="adonet.batch_size">10</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<mapping assembly="Model"/>
</session-factory>
</hibernate-configuration>