ADO.NET Entity framework 连接MySql 提示The specified store provider cannot be found in the configuration

来源:互联网 发布:封装js插件 编辑:程序博客网 时间:2024/05/29 02:03

本机安装了 MySql Connector/Net 6.9.6


http://dev.mysql.com/downloads/connector/net/


使用ADO.NET Entity framework操作MySql数据库,没问题,但是复制到其他主机上运行则提示The specified store provider cannot be found in the configuration...
查找资料,发现在项目里的App.Config添加一下代码得以解决(如下代码),其中<remove invariant="MySql.Data.MySqlClient"/>是为了在已安装了MySql Connector/Net的主机上运行不报错,同时注意修改Version
<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.9.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />    </DbProviderFactories>  </system.data>

在安装好的MySql Connector/Net目录下复制你项目使用的.Net Framework版本对应的DLL,如下图


拷贝MySql.Data.dll、MySql.Data.Entity.dll、MySql.Web.dll到你项目的Bin目录下,到此,打包时附带上这三个Dll,其他电脑在运行你的软件时,无需再额外安装MySql Connector/Net。

0 0