开发者

Mysql, NHibernate and visual studio 2008 configuration

开发者 https://www.devze.com 2023-01-13 07:07 出处:网络
I am a beginer with visual studio 2008 (C#), mysql and NHibernate. I have problems with mysql connector as I don\'t know how to add reference to it.

I am a beginer with visual studio 2008 (C#), mysql and NHibernate.

I have problems with mysql connector as I don't know how to add reference to it.

In my project I have: /lib/mysql-connector-net-6.1.4-src/ (downloaded from http://dev.mysql.com/downloads/mirror.php?id=387799#mirrors)

Now I right click on my project -> addReference -> browse -> What now?

Should I also edit my hibernate configuration?

<hibernate-configur开发者_运维知识库ation xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <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=Pets;Database=pets,User ID=root,Password=;</property>
      <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
      <property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
      <property name="show_sql">false</property>
    </session-factory>
  </hibernate-configuration>

Thanks


You need to add a reference to the MySQL connector DLL that corresponds to the version of .NET you are targeting.

From the link provided, it seems like you downloaded the source code for the MySQL connector, so you'll either need to build this code and take the desired DLL out of the /bin folder afterwards or download a full installer (which will include the binaries) from the second link here:

http://dev.mysql.com/downloads/connector/net/6.1.html

Once you add this DLL to your project, you'll need to edit that NHibernate configuration to update the "connection.connection_string" property with the connection string for your database.

Hope this helps. There is some more documentation available here:

http://dev.mysql.com/doc/refman/5.1/en/connector-net.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号