Reputation: 2434
I have been searching for a solution for this in the last two weeks and tried all the methods mentioned across the web, yet to figure out why this is still happening !
I am able to connect to a Oracle DB from SQL Plus but when i try to connect to it from C# its giving the following error.
{"ORA-12514: TNS:listener does not currently know of service requested in connect descriptor"} System.Exception {Oracle.ManagedDataAccess.Client.OracleException}
SQL plus is resolving the connection using LDAP but in C# I have tried the folloiwng connection strings,
//string strConnectString = "Data Source=XYZ;User ID=user;Password=pwd";
string strConnectString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ABC1234.Xyz.abc)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=XYZ)));User ID=user;Password=pwd";
but both connection strings are causing the error, I am using Oracle.ManagedDataAccess.Client for connectivity.
Can you experts please direct me in the right direction?
Upvotes: 2
Views: 7673
Reputation: 1033
In my case I want to connect to oracle database entity framework and I used scaffold-DbContext and changed the reqular form of connection string used in SQLSERVER to the oracle TNS connection string as the following and its working as expected like this :
Scaffold-DbContext "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Kaash-App1.kaash.local)(PORT=1521)))(CONNECT_DATA=(SID=kaashm)));User ID=trngkaash;Password=kaashnew"
-Provider Oracle.EntityFrameworkCore
-OutputDir Models
-Tables USERS
Upvotes: 0
Reputation: 2434
Just changed the connection string with SID instead of Service_Name, Thanks a lot to the good Friends who has guided me in the right direction.
string strConnectString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ABC1234.Xyz.abc)(PORT=1521)))(CONNECT_DATA=(SID=XYZ)));User ID=user;Password=pwd"
Upvotes: 11