2014-06-12 26 views
2

没有对这里的职位似乎已解决我的错误的特定版本,但我可能只是失去了一些东西......没有实体框架提供发现......有固定名称“System.Data.SqlClient的”

风云作弊:

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" /> 

两者都有连接字符串:

<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" /> 

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

SiteTrackerEntities db = new SiteTrackerEntities(); 
db.Entry(visitorData).State = System.Data.Entity.EntityState.Added; 

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

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. 
  • 确保两者都使用相同版本的EF(6.0)。检查。
  • 试图在连接字符串中输入提供者名称,但已经使用providerName="System.Data.EntityClient"
  • 尝试使用PM控制台删除并重新安装EF。检查。
  • 手动删除Ef引用并阅读它们。检查。
  • WCF服务引用Entity.Framework.SqlServer(版本6.0.0.0)。检查。
  • MVC应用程序具有仅用于WCF服务的数据库的连接字符串(奇怪的是它需要它但没关系)。检查。

我错过了什么?

+0

您是否在WCF项目上通过NuGet安装EF6? – tranceporter

+0

多项目解决方案。在PM控制台中运行它将它添加到两个项目中,同时修改了两个.config文件以同步到同一版本。 Moo指出我正确的方向。 – MetalPhoenix

回答

7

确保在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> 
+0

这样做。它已经在应用程序配置中,但不是web配置。它不再在该行上发生错误,但现在正在讨论没有插入函数存在或一些废话。你会得到答案和投票!谢谢 – MetalPhoenix

+1

问题:即使WCF服务是访问数据库的人,为什么MVC项目需要web.config中的数据信息? – MetalPhoenix

+1

这是因为.net默认使用调用应用程序的配置文件。在大多数情况下,它是主要的Web/Windows应用程序。 – tranceporter

相关问题