WCF和放大器;实体框架和放大器; SQL服务器 - "底层提供程序未能在开放与QUOT; [英] WCF & Entity Framework & SQL Server - "The underlying provider failed on Open"

查看:173
本文介绍了WCF和放大器;实体框架和放大器; SQL服务器 - "底层提供程序未能在开放与QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功运行通过WCF测试客户端测试,直到我尝试与实体框架数据拉。



要确保我没有做任何事情愚蠢的,我从网上下载本教程中,这是做类似的事情的示例代码:的http:// www.codeproject.com/KB/WCF/WCFandEF.aspx



...当我运行它,我得到了一个类似的地方同样的错误

  VAR productEntity =(上接第在context.ProductEntities 
,其中p.ProductID == ID
选择p).FirstOrDefault();



该错误是




底层供应商未能打开。




我可以从一个正常的程序具有相同的连接打开数据库罚款字符串,它似乎是从特定的WCF测试客户端访问数据库。



研究这里和谷歌的基础供应商未能打开。通常表明它是一个连接字符串的问题,但我敢肯定它不是在这种情况下。



所以,现在我希望这是某种权限的问题。



我使用SQL Server和Windows 7,与Visual Studio 2010。



我一直在敲打我的脑袋从昨天起,所以任何帮助或保护头盔赞赏。



编辑,包括连接字符串

 <添加名称=NorthwindEntities
的connectionString =元数据= RES://*/Northwind.csdl |高分辨率://*/Northwind.ssdl |高分辨率:/ /*/Northwind.msl;provider=System.Data.SqlClient;provider
连接字符串=安培; QUOT;数据源=本地主机;初始目录=罗斯文;用户ID = SA; MultipleActiveResultSets =真放; QUOT;
的providerName =System.Data.EntityClient/>


解决方案

此错误意味着100%的问题在连接字符串中



一个很好的方法来创建一个肯定的有效连接字符串是从创建一个新的(虚拟)项目中,添加一个实体框架数据模型,请选择生成模型数据库,选择您需要的连接,然后单击测试Conntection在App.Config中保存实体连接如设置,以确保它的工作原理

确保:......被勾选<。 BR />
比,在你的web / app.config中,你有一个连接字符串,您可以复制粘贴+到你自己的项目。


I am successfully running tests through the the WCF Test Client, until I try to pull in data with Entity Framework.

To make sure I'm not doing anything stupid, I downloaded the sample code from this tutorial, which is doing something similar: http://www.codeproject.com/KB/WCF/WCFandEF.aspx

...and when I run it, I get the same error in a similar place:

var productEntity = (from p in context.ProductEntities 
                     where p.ProductID == id
                     select p).FirstOrDefault();

The error is

The underlying provider failed on Open.

I can open the database fine from a "normal application" with the same connection string, it seems to be specific accessing the DB from the WCF test client.

Research here and on Google for "The underlying provider failed on Open." usual indicates that it's a connection string problem, but I'm pretty sure it's not in this case.

So now I expect it's some sort of permissions problem.

I am using SQL Server and Windows 7, with visual studio 2010.

I have been banging my head since yesterday, so any help or protective head gear appreciated.

Edited to include connection string

<add name="NorthwindEntities" 
     connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider
connection string=&quot;Data Source=localhost;Initial Catalog=Northwind;User ID=sa;MultipleActiveResultSets=True&quot;" 
     providerName="System.Data.EntityClient" />

解决方案

This error means 100% a problem in your connection string.

A good way to create a surely working connection string is to create a new(dummy) project, add an Entity Framework Data Model to it, select "Generate Model from Database", select your required connection, and click "Test Conntection" to be sure it works.
Make sure ""Save entity conection settings in App.Config as:..." is ticked.
Than, in you web/app.Config, you have a Connection String you can copy+paste to your own project

这篇关于WCF和放大器;实体框架和放大器; SQL服务器 - &QUOT;底层提供程序未能在开放与QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆