9
votes

I used this code in hibernate.cfg.xml configuration:

<?xml version="1.0"?>
<hibernate-configuration xmlns= "urn:nhibernate-configuration-2.2">
  <session-factory>

    <!-- SQLServer: Provider --><!--
    <property name="connection.provider"> NHibernate.Connection.DriverConnectionProvider </property>-->

      <!-- SQLServer: Driver -->
    <property name="connection.driver_class"> NHibernate.Driver.MySqlDataDriver </property>

    <!-- SQLServer: Dialeto -->
    <property name="dialect"> NHibernate.Dialect.MySQLDialect </property>

    <!-- SQLServer: Connection String -->
    <property name="connection.connection_string"> Database=nhibernate;Data Source=localhost;User Id=root;Password=xxxx</property>

    <!-- Classe que será utilizada para Proxy
       (LazyLoading) -->
    <property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
  </session-factory>
</hibernate-configuration>

I have a problem to create database.

NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.MySqlDataDriver. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly MySql.Data could not be found. ...

What should I do?

1
Not solve your problem but searching on internet I think it is useful. Be sure of the CASE of the driver name (Sql instead SQL): CORRECT: NHibernate.Driver.MySqlDataDriver INCORRECT: NHibernate.Driver.MySQLDataDriverRiccardo Bassilichi

1 Answers

29
votes

It's simple: add Mysql.Data.dll to the project's bin folder.