NHbernate使用MySql.Data.dll问题
在数据访问层引用MySql.Data.dll,在web.config添加配置如下(版本号要匹配):
其实是6.3.4.0的要与NHibernate3搭配
<runtime> <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1"> <qualifyAssembly partialName="MySql.Data" fullName="MySql.Data, Version=6.3.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"> </qualifyAssembly> </assemblyBinding> </runtime>
附hibernate.cfg.xml
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="WebApp"> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> <!--Data Source=.;Initial Catalog=NhGBook;Integrated Security=True;Pooling=False--> <property name="connection.connection_string"> Data Source=localhost;user=root;password=123456;database=finance; </property> <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property> <property name="adonet.batch_size">10</property> <property name="show_sql">true</property> <property name="use_outer_join">true</property> <property name="command_timeout">10</property> <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> <!--<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu</property>--> <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property> <mapping assembly="DomainModel"/> </session-factory> </hibernate-configuration>
nhibernate版本问题:在app.config或web.config添加配置如下
<dependentAssembly> <assemblyIdentity name="NHibernate" Culture="neutral" publicKeyToken="aa95f207798dfdb4" /> <bindingRedirect oldVersion="3.0.0.2001" newVersion="3.0.0.2002" /> </dependentAssembly>