【发布时间】:2014-06-12 14:06:22
【问题描述】:
这里的帖子似乎都没有解决我的错误的这个特定版本,但我可能只是遗漏了一些东西......
情况:
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="data source=BADLANDS\;initial catalog=SiteTracker;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" 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 服务中使用的数据库的连接字符串(奇怪的是它需要它但没关系)。检查。
我错过了什么?
【问题讨论】:
-
您是否通过 NuGet 在 WCF 项目上安装了 EF6?
-
多项目解决方案。在 PM 控制台中运行它会将其添加到两个项目中,修改两个 .config 文件以同步到相同的版本。 Moo 为我指明了正确的方向。
标签: c# .net asp.net-mvc entity-framework wcf