使用Nibernate遇到的一个错误 Could not compile the mapping document: eDirectory.Domain.Mappings.Customer.hbm.xml
由于代码和配置文件同时配置了 assembly 导致了这个错误。
if (string.IsNullOrEmpty(ConfigurationFileName)) throw new ArgumentException("ConfigurationFileName property was blank"); NhConfigurationInstance = new Configuration(); NhConfigurationInstance.Configure(ConfigurationFileName); NhConfigurationInstance.AddAssembly(typeof(Customer).Assembly); return NhConfigurationInstance;
而配置文件则如下:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"
>
<session-factory name="NHibernate.Test">
<property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property
name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
<property
name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="connection.connection_string">User
ID=scott;Password=123456;Data Source=fortest</property>
<property name="show_sql">false</property>
<property
name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle</property>
<property
name="hbm2ddl.keywords">none</property>
<property
name="cache.use_second_level_cache">true</property>
<property name="cache.use_query_cache" >true</property>
<property
name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider</property>
<mapping
assembly="eDirectory.Domain"/>
</session-factory>
</hibernate-configuration>
解决办法:删除<mapping assembly="mapping assembly="eDirectory.Domain"/> 或者注释掉代码中的配置
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。