Friday, April 25, 2014

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


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:

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

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

Hope this helps!

Post a Comment