Friday, April 25, 2014

Unable to retrieve metadata for unrecognized element 'providers' when adding a controller in VS 2013

Hi,

I was trying to add a new controller in my project using Visual Studio 2013. I was using Code First Entity Framework for my data access. I tried to build and clean the project few times before adding the new controller; but still was getting this error message when  adding a new controller to my web api project.

Here is the error message:


The solution is the following:
1) Open the web.config file in your project.
2) Scroll down until you see entity framework section.
3) This is how it will be looking:

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

4) Remove the providers section.
5) Save and you will be able to add new controllers!

Hope this helps!


Post a Comment