2012-07-31 112 views
2

尝试使用实体框架打开连接时,我不断收到此错误。 我可以从数据库中更新模型,完全没有问题,但是当我在调试中运行代码时,会出现此错误。 (运行在Windows 2008 VM)“底层提供程序在打开时失败”

当错误出现看起来像这样的代码片段:

public partial class SpatialDatabase : global::System.Data.Objects.ObjectContext 
{ 
    try 
    { 
     using (EntityConnection conn = new EntityConnection(this.Connection.ConnectionString)) 
     { 
      conn.Open(); // <== fails here 

      EntityCommand cmd = conn.CreateCommand(); 
      ... 

这是连接到Oracle数据库。

这段代码显然在其他地方运行正常,所以我有一种感觉,这是与连接。 我们正在使用Oracle for .NET(ODAC)驱动程序。我不知道它是64位还是32位,但它在更新模型时起作用,但在调试时不起作用。

(!我会显示额外的代码,如果我知道要显示什么)从app.config中

连接字符串:

<connectionStrings> 
    <add name="SpatialDatabaseContext" connectionString="metadata=res://*/SpatialDatabase.csdl|res://*/SpatialDatabase.ssdl|res://*/SpatialDatabase.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=ds_name_here;PASSWORD=password_here;PERSIST SECURITY INFO=True;USER ID=user_id_here&quot;" providerName="System.Data.EntityClient" /> 
</connectionStrings> 

[编辑]

System.Data.SqlClient.SqlException: 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 

[/编辑]

[编辑]

以上可能是红鲱鱼。我又跑了,并没有;看不到的错误,但我没有看到这样的InnerException:

[Oracle.DataAccess.Client.OracleException] = {"ORA-12154: TNS:could not resolve the connect identifier specified"} 

[/ EDIT 2]

[编辑3]

我试图用EFOracleProvider代替。 它建立好了,但是当我去生成实体模型,我得到这个:

Microsoft (R) EdmGen version 3.5.0.0 
Copyright (C) 2008 Microsoft Corporation. All rights reserved. 

error 7001: The provider did not return a ProviderManifestToken string. 
Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed. 
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) 

Generation Complete -- 1 errors, 0 warnings 

我有32位和安装Oracle客户端组件的64个版本。 如何选择是否运行32位或64位?

[/ EDIT3]

+0

添加您的.config连接字符串(无真实姓名/ PW)。这个错误听起来像是一个配置问题。 – Kaido 2012-07-31 15:38:12

+0

添加.config连接字符串 - 我同意我认为这是一个配置问题,只是不知道什么:( – CompanyDroneFromSector7G 2012-07-31 15:49:54

+0

你有没有得到另一个消息“打开失败”,如“管道上没有进程”或什么 – Kaido 2012-07-31 15:50:36

回答

0

访问连接有关信息,没有修复。

我最终放弃了VM我正在对这个问题,另建(以及别人建了!)

的问题现在已经没有了。

0

我发现一对夫妇的联系,以为他们会帮助你!因此在这里分享。

在参考此博客文章时,http://th2tran.blogspot.in/2009/06/underlying-provider-failed-on-open.html 本节我想从本博客文章与您分享。 “所以IIS试图通过凭证'NT AUTHORITY \ NETWORK SERVICE'访问数据库,我通过SQL Server Management Studio查看了数据库设置,当然,该账户没有被列为允许连接的用户之一所以我加了他,而这个网络应用程序能够成功连接。“

试试看!

如果你已经照顾它,那么请参考以下链接:MSSQL Error 'The underlying provider failed on Open'

希望这有助于!

+0

感谢您的建议瓦伦 - 只是检查:将吨这是相关考虑我在Visual Studio中运行而不是IIS,并且数据库是Oracle而不是SQL Server? – CompanyDroneFromSector7G 2012-07-31 16:19:41

0

对不起,如果上述任何对你没有帮助。我只是说他们,因为你加入[编辑] SQL服务器相关的东西

不管怎么说,请检查下面的SQL Server:http://www.sswug.org/articlesection/default.aspx?TargetID=44331

而在甲骨文的情况下,请参考以下链接,如果他们帮助。 。

http://ora-12154.ora-code.com/ http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/06/30/ora-12154-tns-could-not-resolve-the-connect-identifier-specified-error -while-creating-a-linked-server-to-oracle.aspx

Regards,

Varun的Shringarpure

+0

您的所有链接似乎都与SQL Server相关。也许我不清楚,但我根本不使用SQL Server。感谢您的建议:) – CompanyDroneFromSector7G 2012-08-01 08:41:45

0

The server was not found or was not accessible.

意味着您的连接字符串指向无法找到的服务器。最常见的(至少对我来说)是由于一个错误的Sql Server名称,在你的情况下它可能类似。检查连接字符串点的

Data Source=(local) 

一部分,你可以用其他工具/应用

(例如,在.edmx文件的app.config应指向同一个地方)

+1

我试图连接到Oracle服务器。这个消息出现了一次,我认为这只是一个红鲱鱼。我可以使用相同的连接细节从数据库重建实体模型,但我无法在运行时连接。 – CompanyDroneFromSector7G 2012-08-01 08:47:03

+0

我会复制粘贴从工作文件的配置绝对确定,然后追逐该错误:http://ora-12154.ora-code.com/ – Kaido 2012-08-01 09:21:30

0

在连接字符串中,对于数据源,确保使用完整的描述符而不是来自TNSNames.ora的条目。例如,

`"data source=(DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=**host_name**) (PORT=**1521**)) (CONNECT_DATA= (SERVER=dedicated) (SID=**db_instance**)))"` 

代替

"data source=**my_tns_ds**" 
相关问题