简体   繁体   English

“ System.Data.EntityException”的第一次机会异常。 基础提供程序在打开时失败

[英]First chance exception of 'System.Data.EntityException'. The underlying provider failed on Open

I've been given a site that was created by someone else and I'm now trying to test it. 我得到了一个由其他人创建的网站,我现在正在尝试对其进行测试。 I can compile the system without any problems but when I try to log in to the website, I get the error: 我可以编译系统,没有任何问题,但是当我尝试登录网站时,出现错误:

"EntityException occured. A first chance exception of type 'System.Data.EntityException' occured in System.Data.Entity.dll. Additional info: The underlying provider failed on Open."

Furthermore, if I dig deeper, I see an InnerException of Cannot open database \\"MyDB\\" requested by the login. The login failed. Login failed for user 'name\\\\owner'. 此外,如果我进行更深入的研究,我会看到Cannot open database \\"MyDB\\" requested by the login. The login failed. Login failed for user 'name\\\\owner'.的InnerException Cannot open database \\"MyDB\\" requested by the login. The login failed. Login failed for user 'name\\\\owner'. Cannot open database \\"MyDB\\" requested by the login. The login failed. Login failed for user 'name\\\\owner'.

I've read similar problems on the web and it seems like its a problem with database connections? 我在网络上读过类似的问题,好像它与数据库连接有关? I've tried multiple 'solutions' that include messing around with the connectionString but nothing works. 我尝试了多个“解决方案”,其中包括弄乱connectionString,但没有任何效果。

What I think the system wants to do is connect to a .mdf located in a separate project's App_Data. 我认为系统想要做的是连接到位于单独项目的App_Data中的.mdf。 Anyway, here's the connectionString code that I received originally: 无论如何,这是我最初收到的connectionString代码:

add name="NameServiceContext"
connectionString="Server=tcp:qiu5vg5yhv.database.windows.net,1433;Database=MyDB;User ID=MYID;Password=MYPASS;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
providerName="System.Data.SqlClient"

Quick question, what is the tcp:...... stuff? 快速的问题,什么是tcp:......东西? I'm assuming it was generated somehow, but how? 我假设它是以某种方式生成的,但是如何生成?

I've tried 'fixing' the problem and ended up with something like this: 我已经尝试过“解决”问题,并最终得到如下结果:

add name="NameServiceContext" 
connectionString="data source=./SQLEXPRESS;AttachDbFilename=C:\Users\owner\Documents\MyERP\App_Data\MyDB.mdf;Integrated Security=True;Connect Timeout=30;" 
providerName="System.Data.SqlClient"

Both methods give the same errors and I'm out of ideas. 两种方法都给出相同的错误,我没有主意。 How would I go about fixing this? 我将如何解决这个问题?

Also, when I connect to a db via tools>connect to database > MS SQL db file, I get an option between 2 data sources, ./SQLEXPRESS and (LocalDB)\\v11.0 . 另外,当我通过工具>连接到数据库> MS SQL db文件连接到数据库时,我在./SQLEXPRESS(LocalDB)\\v11.0两个数据源之间选择了一个选项。 Do I have to include both of them? 我必须同时包括两个人吗? If so, how? 如果是这样,怎么办?

The original connection string refers to a Microsoft Azure instance. 原始连接字符串引用Microsoft Azure实例。 A typical connection string to Azure looks like: 与Azure的典型连接字符串如下所示:

Server=tcp:[serverName].database.windows.net;Database=myDataBase;User ID=[LoginForDb]@[serverName];Password=myPassword;Trusted_Connection=False;Encrypt=True;

Your server name is qiu5vg5yhv.database.windows.net . 您的服务器名称是qiu5vg5yhv.database.windows.net Most likely your credentials are incorrect. 您的凭证很可能不正确。

It is as Andrew said, you don't seem to have access to the actual database. 正如安德鲁所说,您似乎无权访问实际的数据库。 Simply download either "SQL Server Management Studio" or "SQL Server Management Studio Express" (depend on which version of database you are using) and try to connect. 只需下载“ SQL Server Management Studio”或“ SQL Server Management Studio Express”(取决于您所使用的数据库版本),然后尝试进行连接。

If you connect successfully, check if you can query the database of your project. 如果连接成功,请检查是否可以查询项目数据库。 If you connect unsuccessfully, contact your system admin to arrange access. 如果连接失败,请与系统管理员联系以安排访问。

If you want to understand more about connectionstring or create one, use the following site for template: http://www.connectionstrings.com/sql-server/ 如果要了解有关连接字符串的更多信息或创建一个连接字符串,请使用以下网站作为模板: http : //www.connectionstrings.com/sql-server/

You can get the necessary database details by viewing the Properties of your database via "SQL Server Management Studio" (right click and select Properties --> View Connection Properties) 您可以通过“ SQL Server Management Studio”查看数据库的属性来获取必要的数据库详细信息(右键单击并选择属性->查看连接属性)

I met the same question. 我遇到了同样的问题。 The key step is here. 关键步骤在这里。 I used vs 2013 update 4. When you configured your SQL in azure, it generated a connect string. 我使用了vs 2013 update4。当您以天蓝色配置SQL时,它生成了一个连接字符串。

在此处输入图片说明

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

相关问题 System.Data.EntityException:基础提供程序在打开时失败 - System.Data.EntityException: The underlying provider failed on Open System.Data.Entity.Core.EntityException:“基础提供程序在打开时失败。” 错误? - System.Data.Entity.Core.EntityException: 'The underlying provider failed on Open.' Error? EntityException:底层提供程序在Open +内部异常上失败 - EntityException: The underlying provider failed on Open + inner exceptions 未处理EntityException基础提供程序无法打开 - EntityException was unhandled the underlying provider failed to open 用户代码未处理System.Data.EntityException - System.Data.EntityException was unhandled by user code System.Data.EntityException”发生在System.Data.Entity.dll中 - System.Data.EntityException' occurred in System.Data.Entity.dll 系统数据实体。 基础提供程序在打开时失败 - System Data Entity. The underlying provider failed on Open 实体框架异常“底层提供程序打开失败” - Entity Framework Exception “The underlying provider failed on Open” 标的提供商无法开放 - The Underlying Provider Failed to open 错误:基础提供程序在打开时失败。 用户的system.data.sqlclient.sqlexception登录失败 - Error: the underlying provider failed on open. system.data.sqlclient.sqlexception login failed for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM