找不到“MySql.Data.MySqlClient”ADO.NET提供程序的实体框架提供程序 [英] No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider
问题描述
完整的错误读取:
未找到MySql.Data.MySqlClientADO.NET提供程序的实体框架提供程序。确保提供程序已注册在应用程序配置文件的entityFramework部分。
但是,我找不到任何建议您在entityFramework部分注册的内容。
其他一些帖子(示例)建议将提供者添加到 system.Data
DbProviderFactories
部分如下:
< DbProviderFactories>
< add
name =MySQL数据提供者
invariant =MySql.Data.MySqlClient
description =.Net Framework Data Provider for MySQL
type =MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data,
Version = 6.2.3.0,Culture = neutral,
PublicKeyToken = c5687fc88969c44d/>
< / DbProviderFactories>
但这并不奏效,因为它声称不变量
名称重复。而且,如果我实际上遍历了 System.Data.Common.DbProviderFactories
,我可以看到最后一个是MySQL提供者:
MySQL数据提供者
。MySQL框架数据提供者
MySql.Data.MySqlClient
MySql.Data.MySqlClient.MySqlClientFactory,MySql。数据,版本= 6.6.5.0,文化=中立,PublicKeyToken = c5687fc88969c44d
所以提供者在那里,但是EF拒绝使用它。任何想法?
我的完整配置如下所示:
;结构>
< configSections>
<! - 有关实体框架配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
< section name =entityFrameworktype =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089requirePermission =false/> ;
< / configSections>
< system.data>
<! - < DbProviderFactories>
< add
name =MySQL数据提供者
invariant =MySql.Data.MySqlClient
description =.Net Framework Data Provider for MySQL
type =MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data,
Version = 6.2.3.0,Culture = neutral,
PublicKeyToken = c5687fc88969c44d/>
< / DbProviderFactories> - >
< /system.data>
< connectionStrings>
< add name =myContextconnectionString =server = ****; User Id = ****; password = ****; Persist Security Info = True; database = myDb
providerName =MySql.Data.MySqlClient/>
< / connectionStrings>
< startup>
< supportedRuntime version =v4.0sku =。NETFramework,Version = v4.5/>
< / startup>
< entityFramework>
< defaultConnectionFactory type =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,EntityFramework>
< parameters>
< parameter value =v11.0/>
< / parameters>
< / defaultConnectionFactory>
< / entityFramework>
< / configuration>
Nevermind。我注意到我已经安装了EF 6。我删除它,并尝试EF 5(NuGet说是最新的稳定版本),它开始工作。
仍然,一个更有用的错误信息将是很好!
I'm trying to use Entity Framework with MySQL and I get the above error. I have the latest MySQL connector installed.
The full error reads:
No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider. Make sure the provider is registered in the 'entityFramework' section of the application config file.
However, I can't find anything that suggests just how you register it in the 'entityFramework' section.
Some other posts (example) suggest adding the provider to the system.Data
DbProviderFactories
section like this:
<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.2.3.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
But that doesn't work because it claims that the invariant
name is duplicated. And, if I actually iterate through the System.Data.Common.DbProviderFactories
I can see the last one is the MySQL provider:
MySQL Data Provider
.Net Framework Data Provider for MySQL
MySql.Data.MySqlClient
MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d
So the provider is there, but EF refuses to use it. Any ideas?
My full config looks like this:
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<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.2.3.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>-->
</system.data>
<connectionStrings>
<add name="myContext" connectionString="server=****;User Id=****;password=****;Persist Security Info=True;database=myDb"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
Nevermind. I noticed that I had EF 6 installed. I removed it and tried EF 5 instead (which NuGet says is the latest stable version) and it started working.
Still, a more useful error message would have been nice!
这篇关于找不到“MySql.Data.MySqlClient”ADO.NET提供程序的实体框架提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!