Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not create the driver from NHibernate.Driver.MySqlDataDriver

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?

like image 214
Halley Avatar asked Dec 02 '10 12:12

Halley


1 Answers

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

like image 173
Halley Avatar answered Oct 05 '22 19:10

Halley