找不到实体框架提供程序...使用不变名称'System.Data.SqlClient'

Met*_*nix 2 .net c# asp.net-mvc wcf entity-framework

这里的帖子似乎都没有解决我的错误的特定版本,但我可能只是遗漏了一些东西......

情况:

MVC网站使用WCF服务.数据保存在WCF服务中.两者都在运行

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
Run Code Online (Sandbox Code Playgroud)

两者都有连接字符串:

    <add name="SiteTrackerEntities" connectionString="metadata=res://*/VisitorInformation.csdl|res://*/VisitorInformation.ssdl|res://*/VisitorInformation.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=BADLANDS\;initial catalog=SiteTracker;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)

站点运行,直到我实际尝试使用(第二行错误)保存到WCF服务中的数据库...

SiteTrackerEntities db = new SiteTrackerEntities();
db.Entry(visitorData).State = System.Data.Entity.EntityState.Added; 
Run Code Online (Sandbox Code Playgroud)

然后我得到了这个可爱的错误:

VisitorInformation.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Run Code Online (Sandbox Code Playgroud)
  • 确保两者都使用相同版本的EF(6.0).校验.
  • 试图在连接字符串中输入提供程序名称但已经使用 providerName="System.Data.EntityClient"
  • 尝试使用PM控制台删除并重新安装EF.校验.
  • 手动删除Ef引用并重新读取它们.校验.
  • WCF服务引用了Entity.Framework.SqlServer(版本6.0.0.0).校验.
  • MVC应用程序具有到仅在WCF服务中使用的数据库的连接字符串(奇怪的是它需要它但是没关系).校验.

我错过了什么?

Moo*_*Moo 6

确保在Web.config或App.config中有类似于以下内容的内容.

<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>
Run Code Online (Sandbox Code Playgroud)