<i id='jSaIO'><tr id='jSaIO'><dt id='jSaIO'><q id='jSaIO'><span id='jSaIO'><b id='jSaIO'><form id='jSaIO'><ins id='jSaIO'></ins><ul id='jSaIO'></ul><sub id='jSaIO'></sub></form><legend id='jSaIO'></legend><bdo id='jSaIO'><pre id='jSaIO'><center id='jSaIO'></center></pre></bdo></b><th id='jSaIO'></th></span></q></dt></tr></i><div id='jSaIO'><tfoot id='jSaIO'></tfoot><dl id='jSaIO'><fieldset id='jSaIO'></fieldset></dl></div>
  • <small id='jSaIO'></small><noframes id='jSaIO'>

    <tfoot id='jSaIO'></tfoot>
      <bdo id='jSaIO'></bdo><ul id='jSaIO'></ul>

      <legend id='jSaIO'><style id='jSaIO'><dir id='jSaIO'><q id='jSaIO'></q></dir></style></legend>

        找不到“MySql.Data.MySqlClient"ADO.NET 提供程序的实体框架提供程序

        时间:2023-05-31
              <tbody id='BgOxz'></tbody>
            <tfoot id='BgOxz'></tfoot>

              <i id='BgOxz'><tr id='BgOxz'><dt id='BgOxz'><q id='BgOxz'><span id='BgOxz'><b id='BgOxz'><form id='BgOxz'><ins id='BgOxz'></ins><ul id='BgOxz'></ul><sub id='BgOxz'></sub></form><legend id='BgOxz'></legend><bdo id='BgOxz'><pre id='BgOxz'><center id='BgOxz'></center></pre></bdo></b><th id='BgOxz'></th></span></q></dt></tr></i><div id='BgOxz'><tfoot id='BgOxz'></tfoot><dl id='BgOxz'><fieldset id='BgOxz'></fieldset></dl></div>
              <legend id='BgOxz'><style id='BgOxz'><dir id='BgOxz'><q id='BgOxz'></q></dir></style></legend>
            1. <small id='BgOxz'></small><noframes id='BgOxz'>

                <bdo id='BgOxz'></bdo><ul id='BgOxz'></ul>

                1. 本文介绍了找不到“MySql.Data.MySqlClient"ADO.NET 提供程序的实体框架提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将 Entity Framework 与 MySQL 一起使用,但出现上述错误.我安装了最新的 MySQL 连接器.

                  完整错误如下:

                  未找到MySql.Data.MySqlClient"ADO.NET 提供程序的实体框架提供程序.确保提供程序已在应用程序配置文件的entityFramework"部分注册.

                  但是,我找不到任何表明您如何在entityFramework"部分注册它的信息.

                  其他一些帖子(示例) 建议将提供程序添加到 system.Data DbProviderFactories 部分,如下所示:

                  <添加名称="MySQL 数据提供程序"不变="MySql.Data.MySqlClient"description="MySQL 的.Net Framework 数据提供程序"type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,版本=6.2.3.0,文化=中性,PublicKeyToken=c5687fc88969c44d"/></DbProviderFactories>

                  但这不起作用,因为它声称 invariant 名称是重复的.而且,如果我真的遍历 System.Data.Common.DbProviderFactories,我可以看到最后一个是 MySQL 提供程序:

                  MySQL 数据提供程序用于 MySQL 的 .Net Framework 数据提供程序MySql.Data.MySqlClientMySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d

                  所以提供者在那里,但EF拒绝使用它.有什么想法吗?

                  我的完整配置如下:

                  <预><代码><配置><configSections><!-- 有关实体框架配置的详细信息,请访问 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><系统数据><!--<DbProviderFactories><添加名称="MySQL 数据提供程序"不变="MySql.Data.MySqlClient"description="MySQL 的.Net Framework 数据提供程序"type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,版本=6.2.3.0,文化=中性,PublicKeyToken=c5687fc88969c44d"/></DbProviderFactories>--></system.data><连接字符串><add name="myContext" connectionString="server=****;User Id=****;password=****;Persist Security Info=True;database=myDb"providerName="MySql.Data.MySqlClient"/></connectionStrings><启动><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></启动><实体框架><defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"><参数><参数值="v11.0"/></参数></defaultConnectionFactory></entityFramework></配置>

                  解决方案

                  没关系.我注意到我安装了 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 提供程序的实体框架提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL:ALTER IGNORE TABLE ADD UNIQUE,什么会被截断? 下一篇:Mysql 选择不同

                  相关文章

                      • <bdo id='WUwN7'></bdo><ul id='WUwN7'></ul>
                      <legend id='WUwN7'><style id='WUwN7'><dir id='WUwN7'><q id='WUwN7'></q></dir></style></legend>

                    1. <tfoot id='WUwN7'></tfoot>

                      <small id='WUwN7'></small><noframes id='WUwN7'>

                      <i id='WUwN7'><tr id='WUwN7'><dt id='WUwN7'><q id='WUwN7'><span id='WUwN7'><b id='WUwN7'><form id='WUwN7'><ins id='WUwN7'></ins><ul id='WUwN7'></ul><sub id='WUwN7'></sub></form><legend id='WUwN7'></legend><bdo id='WUwN7'><pre id='WUwN7'><center id='WUwN7'></center></pre></bdo></b><th id='WUwN7'></th></span></q></dt></tr></i><div id='WUwN7'><tfoot id='WUwN7'></tfoot><dl id='WUwN7'><fieldset id='WUwN7'></fieldset></dl></div>