简体   繁体   English

带有代理的 WCF 服务无法连接到 EntityFramework

[英]WCF Service with Proxy cannot connect to EntityFramework

I want to implement a WCF service with a proxy.我想用代理实现 WCF 服务。 The service and proxy are situated in 2 different projects.服务和代理位于 2 个不同的项目中。 The entityFramework is in the Service project. entityFramework 位于 Service 项目中。 And in the proxy's app.config I put the connection string as below:在代理的 app.config 中,我将连接字符串如下:

<add name="foodOrderEntities" connectionString="metadata=res://*/foodOrderEF.csdl|res://*/foodOrderEF.ssdl|res://*/foodOrderEF.msl;provider=System.Data.SqlClient;
provider connection string=&quot;data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\foodOrder.mdf;integrated security=True;connect timeout=30;
MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

解决方案的地图

But when I try to invoke the method with the service test client I get the following exception: @"The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information."但是,当我尝试使用服务测试客户端调用该方法时,我收到以下异常: @"The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' 在 ADO 的应用程序配置文件中注册无法加载具有不变名称“System.Data.SqlClient”的 .NET 提供程序。请确保使用程序集限定名称并且程序集可用于正在运行的应用程序。请参阅http://go.microsoft.com/ fwlink/?LinkId=260882了解更多信息。”

Please anyone could tell me how can I set up the connection string in such a way that the proxy project serviceHost can access the database successfully?请任何人都可以告诉我如何设置连接字符串以使代理项目 serviceHost 可以成功访问数据库? Or do I need to crate another project independently for the EF object and then add reference?或者我是否需要为 EF 对象独立创建另一个项目,然后添加引用?

Sorry, guys I found another post that is relevant to this issue.抱歉,伙计们,我找到了另一篇与此问题相关的帖子。 No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient' 未找到具有不变名称“System.Data.SqlClient”的 ADO.NET 提供程序的实体框架提供程序

after all, what I need to do is just to add the reference of EntityFramework.SqlServer.dll to the proxy project.毕竟,我需要做的只是将EntityFramework.SqlServer.dll的引用添加到代理项目中。

Try installing the Nuget Entity Framework download in the service project.尝试在服务项目中安装 Nuget 实体框架下载。 I'm pretty sure both the Service project and the ADO.NET Data layer project should have the Entity Framework installed.我很确定服务项目和 ADO.NET 数据层项目都应该安装实体框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM