0

I can't find the exact issue I have on here or anywhere.

I have an ASP.Net MVC WebApi (MVC 5.1.0, Framework 4.5.1) project that uses Oracle.DataAccess. It runs on the local IIS server via a URL that's in my hosts file. It has a connection string connecting to an Oracle database. It works fine.

I have a 'normal' ASP.Net MVC (MVC 5.2.2, Framework 4.5.2) project that uses Oracle.ManagedDataAccess and Dapper. It runs on the local IIS server via a URL that's in my hosts file. It uses the SAME connection string (barring the providerName) to (attempt to) connect to an Oracle database. it does not work, throwing

ORA-12154: TNS:could not resolve the connect identifier specified

when I try to open the connection.

   <add name="OurName" connectionString="Data Source=xxxxx_migration2;Persist Security Info=True;User ID=OurUserName;Password=thepassword;Enlist=False;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=30;Incr Pool Size=5;Decr Pool Size=2;" providerName="Oracle.ManagedDataAccess.Client"/>

TNSNames.ORA is fine [as you'd reckon given that the exact same connection string works in the other project], there are no brackets in the project file paths (a very obscure issue I found in my researches), ORACLE_HOME is pathed... I am stumped.

I know Dapper extends the connection object - does it have any really funky weird requirements that might be causing this?

EDIT: If I switch the 'normal' ASP.Net MVC (and connection string providerName parameter) to Oracle.DataAccess, and don't use Dapper I can connect.

kpollock
  • 3,899
  • 9
  • 42
  • 61

2 Answers2

2

In the end, I needed to make more config file changes than I thought, in order to make Oracle.ManagedDataAccess work (Dapper was not an issue).

see this blog article

and the accepted answer here

It's a little bit annoying, and a change from the past situation to have to manually specify the location of TNSNAMES.ORA in the config file - but hey, it's a config file after all.

Community
  • 1
  • 1
kpollock
  • 3,899
  • 9
  • 42
  • 61
0

In my case, in Web.config file, oracle.manageddataaccess.client -> dataSources tag, alias name was wrong. Once changed, it worked.