In my setup I have a .NET application built with Visual Studio 2015 trying to access data on an Oracle 12c database using Entity Framework 6.
Here's what I did to acchieve that:
- I followed a tutorial at oracle.com on how to use nuget to install the Official Oracle ODP.NET, Managed Entity Framework Driver and its dependencies.
- I ensured that the tnsnames.ora and sqlnet.ora can be found. (The environment variable TNS_ADMIN is configured correctly)
- I enabled trace logging for the oracle driver to see what is actually happening here.
- I created an EDMX file that maps some entities (This already required the workaround described below)
Here is what my App.config looks like (linebreaks introduced to improve readability):
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TraceLevel" value="7" />
<setting name="TraceOption" value="0" />
<setting name="TraceFileLocation" value="C:\Temp" />
<setting name="TNS_ADMIN" value="c:\Temp\tns" />
</settings>
</version>
</oracle.manageddataaccess.client>
<connectionStrings>
<add name="MyModel"
connectionString="metadata=res://*/UDBModel.csdl|res://*/UDBModel.ssdl|res://*/UDBModel.msl;
provider=Oracle.ManagedDataAccess.Client;
provider connection string="User Id=*****;Password=*****;Data Source=MYDATASOURCE.WORLD;""
providerName="System.Data.EntityClient" />
When trying to access the database this fails with an exception:
"ORA-12533: Netzwerksession: Syntaxfehler bei Verbindungstransportadresse"
which according to the oracle docs translates to
"ORA-12533: TNS: illegal ADDRESS parameters"
The trace log shows that the tnsnames.ora gets resolved correctly.
When using the IP-address and the port instead of the TNS name the connection works fine. But as the tnsnames.ora gets managed by the database administrators in our company, addressing the servers using their IP-address is not an option.
I should also note that older drivers (e.g. the Oracle.DataAccess.dll) have no problems accessing the database using this setup.
EDIT: Here is tnsnames.ora file as I use it now:
MYDATASOURCE.WORLD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = MYDATASOURCE))
(ADDRESS = (COMMUNITY = TCP.world)(PROTOCOL = TCP)(Host = myds.example.com)(Port = 1530)))
(CONNECT_DATA = (SID = MYDATASOURCE))
)
What am I doing wrong here?
NB: There are questions similar to this. However, the solutions that helped in that cases did not help here, and the exception encountered there are different from the one encountered here:
- Opening Oracle OleDb connection succeeds, while managed driver connection fails
- Unable to connect to Oracle using TNS and C#
- Can't connect to Oracle using tns
- Entity Framework Code First and Oracle ODAC 12c Release 3 Error
- Oracle.ManagedDataAccess not resolving alias in connection string
- Entity framework connection with oracle databse