views:

16

answers:

1

Hi,

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-configuration 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

A: 

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

Ben Hoffstein
Yes it's true. I downloaded source code - not .msi file :)After installed I clicked:Add reference -> .net (tab) -> Mysql.DataI also had to change Mysql.Data reference property "Local Copy" to true.
knagode