实体框架的基础提供失败的开放 [英] Entity Framework The underlying provider failed on Open

查看:197
本文介绍了实体框架的基础提供失败的开放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的连接字符串:

Below is my connection string:

的connectionString =元数据= RES:// /EDMX.Test.csdl | RES:// 的/EDMX.Test.ssdl|res://*/EDMX.Test.msl;provider=System.Data.SqlClient;provider
连接字符串= QUOT;数据源= home_computer;初始
目录= db_Test;坚持安全信息= TRUE;用户
ID =为testUser;密码= $ 1234; MultipleActiveResultSets = TRUE"

connectionString="metadata=res:///EDMX.Test.csdl|res:///EDMX.Test.ssdl|res://*/EDMX.Test.msl;provider=System.Data.SqlClient;provider connection string="Data Source=home_computer;Initial Catalog=db_Test;Persist Security Info=True;User ID=testUser;Password=$1234;MultipleActiveResultSets=True""

下面是程序卡死代码:

EDMX.TestingEntity context = new EDMX.TestingEntity();

var query = from t in context.User
            where t.UserName == _userName
            select t;



运行上面的代码后,我检查变量查询,发现了一个异常

After running the above code, I check the variable query and found an exception

基础提供开放式失败。

我检查


  1. 服务器和计算机之间的连接是正常的

  2. 我可以登录到使用用户名testuser的数据库与密码$ 1234

  3. 我已签该权限已经被授予为testUser数据库(SQL Server)的安全设置

为什么会出现这种异常情况?我使用.NET 4.5

Why does this exception happen? I'm using .net 4.5

补充:

我再次尝试,看看内部异常,它是:建立到SQL Server的连接发生
与网络相关的或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (provider:命名管道提供程序,error:40 - 无法打开到SQL Server的连接)

I tried again, look at the inner exception and it was: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

我知道这可能是网络的问题,但我已经关掉服务器的防火墙,也是我的计算机并再次尝试,但还是没有成功。

I know it might be a network problem but I've turned off the firewall of server and also my computer and tried again but still not success..

刚才复制ConnectionString,以一个程序测试这个连接,它运作良好。

Just now Copied the connectionstring to a program to test this connection and it was functioning well..

我刚刚回滚所有更改并再次测试和它的工作

I just rollback all changes and test again and it worked

推荐答案

似乎是一个连接问题。您可以使用数据链接属性找到连接是否正常。做到以下几点,

Seems like a connection issue. You can use the Data link properties to find if the connection is fine. Do the following,

创建一个空白的记事本,将其重命名为X.UDL
双击打开它,连接选项卡下选择服务器名称/输入名称
使用了正确的凭据和DB
OK保存它。

Create a blank notepad and rename it to "X.UDL" Double click open it, under connections tab choose the server name/enter the name use the correct credentials and DB OK to save it.

现在使用记事本打开该文件,并检查一下,比较一下连接字符串属性与此..

Now open the file in Notepad and check, compare the connection string properties with this..

这篇关于实体框架的基础提供失败的开放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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