实体框架:无法识别的元素“供应商”异常 [英] Entity Framework: Unrecognized element 'providers' exception

查看:452
本文介绍了实体框架:无法识别的元素“供应商”异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用实体框架5.0.0使用.NET 4.0,我得到一个无法识别的元素供应商例外,在运行时。其实在.NET 4.0这是当我做一个安装包的NuGet已装入实体框架的4.4.0版本。当我从资源管理器中查看文件的属性,我可以看到这一点:

下面是我的配置文件

 < configSections>
    <节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本= 4.4.0.0,文化=中性公钥= b77a5c561934e089requirePermission =FALSE/>
  <! - 有关实​​体框架配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468  - >< / configSections>
  <的ConnectionStrings>
    <添加名称=XXX connectionString="metadata=res://*/StreetMusicModel.csdl|res://*/StreetMusicModel.ssdl|res://*/StreetMusicModel.msl;供应商= MySql.Data.MySqlClient;提供连接字符串='服务器= xxx.net;用户ID = XXX;密码= XXX;数据库= XXX'的providerName =System.Data.EntityClient/>
  < /的ConnectionStrings>
  <的EntityFramework>
    < defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,的EntityFramework>
      <参数>
        <参数值=12.0/>
      < /参数>
    < / defaultConnectionFactory>
    <供应商>
      <供应商invariantName =MySql.Data.MySqlClientTYPE =MySql.Data.MySqlClient.MySqlProviderServices,MySql.Data.Entity/>
    < /供应商>
  < /的EntityFramework>
 

我感觉实体框架4.4.0是无法识别的标记。可我只是删除或重命名节?当我删除了部分我得到另一个异常:基础提供失败的打开

解决方案

我使用的NuGet降级EF从6版本5.0.0版本后,以前有这个问题

。我认为这个问题是,加入EF V6发动机,但降级后不会被删除时,提供程序的配置添加。所以,你可以简单地删除配置,它会正常工作:

 <的EntityFramework>
< defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,的EntityFramework>
  <参数>
    <参数值=12.0/>
  < /参数>
< / defaultConnectionFactory>< /的EntityFramework>
 

I get an Unrecognized element 'providers' exception at runtime when I use Entity Framework 5.0.0 with .NET 4.0. Actually with .NET 4.0 it's the version 4.4.0 of Entity Framework that is loaded when I do an install-package with NuGet. When I check the properties of the file from explorer I can see this:

Here is my config file

 <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="xxx" connectionString="metadata=res://*/StreetMusicModel.csdl|res://*/StreetMusicModel.ssdl|res://*/StreetMusicModel.msl;         provider=MySql.Data.MySqlClient;provider connection string='         server=xxx.net;         user id=xxx;         password=xxx;         database=xxx'" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
    </providers>
  </entityFramework>

I have the feeling Entity Framework 4.4.0 is not able to recognize the tag. Can I just remove or rename the section? When I remove the section I get another exception: The underlying provider failed on Open.

解决方案

I had this issue before after downgrading EF from version 6 to version 5.0.0 using Nuget. I think the issue is that the providers configuration is added when adding EF v6 but not removed after downgrade. So, you can just simply remove the configuration and it will work fine:

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="v12.0" />
  </parameters>
</defaultConnectionFactory></entityFramework>

这篇关于实体框架:无法识别的元素“供应商”异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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