.NET的MySQL Connector冲突DbProviderFactories [英] .NET MySQL Connector Conflicting DbProviderFactories

查看:746
本文介绍了.NET的MySQL Connector冲突DbProviderFactories的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是与实体框架4 .NET的MySQL Connector,一切伟大的工作,但我想在服务器上部署时,打包与我的应用MySQL客户端的DLL文件,所以我们不必担心安装MySQL上每个服务器,每个应用程序将只具有正确的副本,它需要。

I'm using the .NET MySQL Connector with Entity Framework 4, and everything worked great but I wanted to package the MySQL client DLL files with my application when deployed on servers so we don't have to worry about installing mysql on each server, each application will just have the correct copy that it needs.

要做到这一点,我确信MySQL的引用了复制本地设置,这样他们就被复制到bin文件夹,并添加以下到我的app.config:

To make this possible, I made sure the MySQL references had "Copy Local" set so they would be copied to the bin folders and added the following to my app.config:

<system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
</system.data>

这工作,我能够在没有远程服务器上安装的MySQL部署应用程序,但现在我有我的本地开发机器上的问题(如果我的的安装MySQL连接器),和我得到这个错误时,EF试图连接:

This works and I am able to deploy the app without installing mysql on the remote server, but now I have a problem on my local dev machine(where I do have the MySQL connector installed), and I'm getting this error when EF tries to connect:

列'InvariantName'约束是唯一的。价值
'MySql.Data.MySqlClient'已经存在。

如果我注释掉XML我上述在App.config增加,错误消失。因为在系统上安装相同的驱动程序,并在machine.config这是可能的。

If I comment out the XML I added above in the app.config, the error goes away. This is likely because the same driver is installed on the system and is in the machine.config.

解决方案是什么?我宁可不要手动评论,注释,这取决于系统的I构建应用程序就行了。

What is the solution? I would rather not have to manually comment and uncomment the line depending on which system I build the application for.

推荐答案

尝试添加<删除/> 在webconfig不变=MySql.Data.MySqlClient。在你的电脑,你已经安装了MySQL和你的machine.config中的连接器由DbProviderFactories增加一个项目已被修改。所以,如果你把另一个MySQL数据提供程序在你的web.config,它就像如果你正在尝试两次注册相同的事情。

try to add < remove invariant="MySql.Data.MySqlClient" / > in your webconfig. On your computer, you have installed the Connector for MySql and your machine.config have been modified by adding an item in the DbProviderFactories. So if you put another MySql Data Provider in your web.config, its like if you are trying to register the same thing twice.

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
</system.data>

这篇关于.NET的MySQL Connector冲突DbProviderFactories的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆