Entity Framework data provider not found, entityclient

こ雲淡風輕ζ 提交于 2019-12-07 10:58:51

问题


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?


回答1:


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/




回答2:


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>


来源:https://stackoverflow.com/questions/17220362/entity-framework-data-provider-not-found-entityclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!