简体   繁体   English

在GAC中没有MySql.Data的流畅NHibernate连接到MySql

[英]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. 我想这样做,因为每次我从安装程序项目发布或创建安装程序时,它总是失败,因为它无法连接到MySql。

The error says : 错误说:

Unable to find the requested .Net Framework Data Provider. 找不到请求的.Net Framework数据提供程序。 It may not be installed. 它可能没有安装。

In my development PC, MySql.Data is already added to GAC so it doesn't create any problem. 在我的开发PC中,MySql.Data已经添加到GAC中,因此不会造成任何问题。

Can it be done? 能做到吗 I already set Copy Local = true. 我已经设置了Copy Local = true。

This is my current FluentConfiguration : 这是我当前的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

MySql.data.dll must reside beside the assembly containing the code you posted. MySql.data.dll必须位于包含您发布的代码的程序集旁边。 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. 另外, .Provider("MySql.Data.MySqlClient").Driver<NHibernate.Driver.MySqlDataDriver>()是多余的,因为您已经指定了MySQLConfiguration.Standard ,它已经设置了驱动程序和提供程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM