Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework data provider not found, entityclient

First off, I've found many questions and many answers related or perceived identical to my issue however nothing seems to be working out for me.

I have a brand new templated MVC4 website, a brand new database in a fresh install of sql server 2008 r2. I ran aspnet_regsql on the database and created all the tables I created the .edmx model which generated the connectionstring in my web.config.

<connectionStrings>
  <add name="TestEntities" connectionString="metadata=res://*/Models.Test.csdl|res://*/Models.Test.ssdl|res://*/Models.Test.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=WEBSRV\SQLEXPRESS;initial catalog=Test;persist security info=True;user id=Test;password=Test#1337;multipleactiveresultsets=True;App=EntityFramework&quot;"  providerName="System.Data.EntityClient" />
</connectionStrings>

Building the website returns me the error Unable to find the requested .Net Framework Data Provider. It may not be installed.

There is no self closing <DbProviderFactories/> in my machine.config The same issue happens wether I run the website locally in the visual studio web host or on my webserver's IIS. I have not installed any NuGet packages

Why do I get this error?

like image 883
Perry Avatar asked Jun 20 '13 17:06

Perry


2 Answers

Right, I figured out the issue.

You cannot use that connectionstring for anything else than the edmx connection. The way I have it in my web.config makes the website use that same connectionstring for the membership stuff too, which is not compatible with the System.Data.EntityClient provider and needs the System.Data.Sqlclient in my case. Adding a second connectionstring, minus the Entity Framework stuff in it and having that referenced by the membership provider attributes in the web.config removes all errors and allows the page to render and request stuff from the SQL server.

Nightmare over, can return to work on my website. o/

like image 180
Perry Avatar answered Oct 13 '22 12:10

Perry


That is the wrong type of connection string. That is for a model first (EDMX) type connection. You need a code first connection string. Try using a standard connection string such as:

 <connectionStrings>
    <add name="MyDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=(local);Initial Catalog=your_database;Integrated Security=True;Application Name=your_app_name" />
</connectionStrings>
like image 43
LCarter Avatar answered Oct 13 '22 11:10

LCarter