19

I get a message error whenever I try to add a controller with Entity framework template but I keep getting a error message

    unable to retrieve metadata for 'path' unrecognized element providers. 
         (C:\Users\user\appdata\local\Temp-mp6124.tmp line 78)

I know it's something related to connection string so here is my connection string

  <connectionStrings>
    <add name="NoktatyContext" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=NoktatyContext-20140122154208; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|NoktatyContext-20140122154208.mdf" providerName="System.Data.SqlClient" />
  </connectionStrings>
Mohamed Naguib
  • 1,592
  • 6
  • 21
  • 31

2 Answers2

43

I was able to fix this issue by removing the <providers> section of the configuration file.

This:

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  <providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  </providers>
</entityFramework>

Becomes this:

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>

I had this issue this morning and just found the fix. If you don't specify the database (and provider I guess) EF will default to SQL Server Express.

macoms01
  • 1,099
  • 12
  • 22
  • 1
    Awesome man! I just wanted to add, for the people that are following the ASP.NET MVC tutorial on w3schools, this was the solution for me. – edgarpetrauskas Mar 07 '14 at 10:59
  • 4
    The reason for this is if you start a project targeting .NET 4.5 and then use a version of EntityFramework in a referenced assembly which isn't expecting that element. I.e. a version of EF prior to v5 (or EFv5 itself for .Net 4.0, which is actually EFv4.4) – theyetiman Apr 17 '14 at 16:12
  • In my case I had duplicate providers and multiple entityFramework tags in my app.config. I combined them under one entityFramework tag and this resolved my problem. – Peter H Jul 21 '14 at 05:34
3

MVC scaffolding does not support Entity Framework 6 or later

Please unistall current version Entity Framework, vs Install-Package EntityFramework -Version 5.0.0.

Delete tag ...

Restart VS

OK