Oracle.ManagedDataAccess: TNS: Failed to determine the specified connection identifier

I get the following error when trying to connect to an Oracle database from a new ASP.NET MVC 4 application: "ORA-12154: TNS: Could not resolve the specified connection identifier." I am using the Oracle.ManagedDataAccess DLL (version 4.121.1.0) to try to connect to the Oracle 10g database. Here's the thing - I have a test integration build that successfully connects to the database using this minimal App.config:

<connectionStrings> <add name="OracleConnection" connectionString="DATA SOURCE=TNS_NAME;PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx" providerName="Oracle.ManagedDataAccess.Client" /> </connectionStrings> 

However, if I try to run my web application with all the crazy Web.config settings, I get the error message "ORA-12154: TNS: Could not resolve the specified connection identifier". What am I doing wrong? Why is my configuration for a test integration build so simple and complex for Web.config? Here are the relevant sections of my Web.config (taken from Deploying and Configuring ODP.NET to Work Without Installing with Entity Framework ):

custom configSection:

 <configSections> <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> </configSections> 

corresponding configuration section:

  <oracle.manageddataaccess.client> <version number="*"> <edmMappings> <edmMapping dataType="number"> <add name="bool" precision="1"/> <add name="byte" precision="2" /> <add name="int16" precision="5" /> </edmMapping> </edmMappings> </version> </oracle.manageddataaccess.client> 

custom system.data node:

  <system.data> <DbProviderFactories> Remove in case this is already defined in machine.config <remove invariant="Oracle.DataAccess.Client" /> <remove invariant="Oracle.ManagedDataAccess.Client" /> <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> </DbProviderFactories> </system.data> 

EntityFramework node:

  <entityFramework> <defaultConnectionFactory type="Victoria.Data.OracleConnectionFactory, EntityFramework" /> </entityFramework> 

Update 1 : after reading http://docs.oracle.com/cd/E16655_01/win.121/e17732/featConfig.htm#ODPNT8161 I tried to change my Web.config oracle.manageddataaccess.client to the next one and it works. However, it looks like the connectionString node is referencing the TNS name. And this additional link is to the same TNS name file.

  <oracle.manageddataaccess.client> <version number="*"> <dataSources> <dataSource alias="SIEBMATS" descriptor="(DESCRIPTION=(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.yyy.zzz)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = siebmats)))" /> </dataSources> <edmMappings> <edmMapping dataType="number"> <add name="bool" precision="1"/> <add name="byte" precision="2" /> <add name="int16" precision="5" /> </edmMapping> </edmMappings> </version> </oracle.manageddataaccess.client> 
+6
source share
2 answers

One thing you can try is the connection string: connectionString = "Data source = // SERVER: PORT / INSTANCE_NAME; USER = XXX; PASSWORD = XXX".

Useful links here: http://www.connectionstrings.com/oracle/ http://docs.oracle.com/cd/E51173_01/win.122/e17732/featConnecting.htm#ODPNT169

It also helped me having issues with EF: Deploying and configuring ODP.NET to work without installing with Entity Framework

Hope that helped.

+6
source

My problem was in the incorrect / incomplete version of the Oracle driver with 11.2.0 installed. I added another version 12.2.0, didn’t change anything in web.config, and it worked

0
source

All Articles