Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

enter image description here

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
365 views
Welcome To Ask or Share your Answers For Others

1 Answer

I had this issue 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 content within the <providers> tags and the tags themselves and it will work fine:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...