Samuel Adam
Samuel Adam

Reputation: 1337

Fluent NHibernate connection to MySql without MySql.Data in GAC

The question's title pretty much says it all.

I wanted to do so, because every time I publish or create installer from installer project, it always failed because it cannot connect to MySql.

The error says :

Unable to find the requested .Net Framework Data Provider. It may not be installed.

In my development PC, MySql.Data is already added to GAC so it doesn't create any problem.

Can it be done? I already set Copy Local = true.

This is my current FluentConfiguration :

 _sessionFactory = Fluently.Configure()
                .Database(MySQLConfiguration
                    .Standard
                    .ConnectionString(_systemSetting.ConnectionString)
                    .Provider("MySql.Data.MySqlClient")
                    .Driver<NHibernate.Driver.MySqlDataDriver>())
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<EmployeeMap>())
                .BuildSessionFactory();

Thanks.

Update : MySql.Data.dll

Upvotes: 2

Views: 1252

Answers (1)

Firo
Firo

Reputation: 30813

MySql.data.dll must reside beside the assembly containing the code you posted. Also .Provider("MySql.Data.MySqlClient") and .Driver<NHibernate.Driver.MySqlDataDriver>() are redundant since you already specified MySQLConfiguration.Standard which already does set driver and Provider.

Upvotes: 1

Related Questions