Open operation failed due to underlying provider

While attempting to establish a connection using entity framework on a Windows 2008 VM, I consistently encounter an error. The problematic code block appears as follows and pertains to an Oracle database.

Question:

Encountering an error while attempting to establish a connection using
entity framework
, I face no issues when updating the model from the database. However, during debugging, the aforementioned error persists, despite operating on a Windows 2008 VM.

This is how the code snippet appears where the error is located.

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();
            ...

This refers to linking with an Oracle database.

It seems that the issue is related to the connection because the code runs fine in other places. Our driver is the Oracle for .NET (ODAC), but I am unsure whether it is the 64-bit version or not. It is functional when updating the model, but not during debugging.

If I had more information on what to present, I would display supplementary code.

connection string
from app.config:


  

[Edit]

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)

[/Edit]

[Edit2]

The preceding statement could be a distraction. Upon running it again, the aforementioned error was not observed. However, an InnerException was noticed.

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

[/Edit2]

[Edit 3]

I attempted to utilize the EFOracleProvider as a substitute. Although it compiles successfully, I encounter an issue when attempting to create the entity model, which results in the following error message.

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

The Oracle client components are installed in both 32 bit and
64 bit
versions. How can I determine which version to use?

[/Edit3]


Solution 1:

I apologize if the aforementioned information was not beneficial to you. I included it based on your inclusion of
SQL Server
-related content in the [Edit].

Kindly review this resource on SQL Server at http://www.sswug.org/articlesection/default.aspx?TargetID=44331.

For Oracle related queries, kindly check out the following links to see if they are useful.

The website link for the issue is http://
ORA-12154
.ora-code.com/. Additionally, there is a blog post on MSDN regarding the error message “could not resolve the
connect-identifier
specified” that occurs when trying to create a linked server to Oracle, which can be found at http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/06/30/
ora-12154-tns
.

Regards,

Varun Shringarpure


Solution 2:


I stumbled upon a few links that might come in handy for you, so I thought I’d share them here.

This blog post (http://th2tran.blogspot.in/2009/06/
underlying-provider-failed
-on-open.html) discusses an issue where IIS attempts to access a database using the credential ‘

NT AUTHORITY
NETWORK SERVICE’, but this account is not listed as an allowed user in SQL Server Management Studio. The author adds the account and the web app is then able to connect to the database.

Try this out!

In case you have already dealt with the matter, kindly check out the link
MSSQL Error
titled ‘The
underlying provider failed
on Open’.

Hope this helps!


Solution 3:


Ensure that you utilize the complete descriptor in the datasource connection string rather than relying on the TNSNames.ora entry. For instance, …

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

instead of

"data source=**my_tns_ds**"


Solution 4:

The server was either not found or not reachable.

It indicates that the server referenced in your connection string is inaccessible, often caused by an incorrect Sql Server name. You may be experiencing a similar issue. Please verify the details.

Data Source=(local) 

One aspect of the connection string refers to a connection that can be reached through a different application or tool.

(The location referenced by

app.config

in the

.edmx

file should be identical.)

Frequently Asked Questions

Posted in Uncategorized