尝试使用实体框架打开连接时,我不断收到此错误。 我可以从数据库中更新模型,完全没有问题,但是当我在调试中运行代码时,会出现此错误。 (运行在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="DATA SOURCE=ds_name_here;PASSWORD=password_here;PERSIST SECURITY INFO=True;USER ID=user_id_here"" 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]
添加您的.config连接字符串(无真实姓名/ PW)。这个错误听起来像是一个配置问题。 – Kaido 2012-07-31 15:38:12
添加.config连接字符串 - 我同意我认为这是一个配置问题,只是不知道什么:( – CompanyDroneFromSector7G 2012-07-31 15:49:54
你有没有得到另一个消息“打开失败”,如“管道上没有进程”或什么 – Kaido 2012-07-31 15:50:36