3

I have done enough research but can't find an answer.

I have an Oracle DB which I am using with my ADO.NET and it is working fine. However, I would like to use it with Entity Framework 6. Since DB is already in place, I am not going to do "Code First" approach. Below are the issues I am having. Please keep them in mind before jumping to a conclusion.

  • I have VS 2012 with Old ODP Driver. VS is asking me to upgrade. CANT
  • I can't use EDM to generate Diagrams and Code, since I don't have latest ODAC installed and I don't get the option to connect to Oracle DB
  • If I try to use the same connection string with EF which is working fine with ADO.NET then I get followig error

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

Note I am using LDAP to connect to Oracle DB.

I also tried generating an empty EDM and added a new connection string as followed, then I got a different error.

<add name="EF" connectionString="metadata=res://*/Model1.csdl
                                |res://*/Model1.ssdl
                                |res://*/Model1.msl;
                                provider=Oracle.ManagedDataAccess.Client;
                                provider connection string=&quot;data source=MY_SERVICE;password=MY_PASSWORD;persist security info=True;user id=MY_USERID&quot;"
                                providerName="System.Data.EntityClient" />

The entity type is not part of the model for the current context.

My questions.

  • Is there a workaround for above issues.
  • Is there a way to Map Oracle TABLES, STORED PROCEDURES, FUNCTIONS etc. manually?

I know above doesn't make much sense but these are the constraints I have. I am trying to Avoid Long/Old ADO.NET code. If it cannot be done then it is fine as well.

Thanks in advance for your input.

programmerboy
  • 341
  • 5
  • 15

1 Answers1

0

It is not so clear what you problem is, because terms like "ODAC" or "ADO.NET" are quite ambiguous.

ODAC is a software package which contains several providers and drivers. Please state clearly the provider (e.g. OraOLEDB.Oracle or MSDAORA) and references (e.g. Oracle.DataAccess.Client or System.Data.OracleClient) and tell us which one is working or not working.

Anyway, it looks like you have problems with ODP.NET Managed Provider (Oracle.ManagedDataAccess.Client), so focus on that one. Apparently it does not find the sqlnet.ora and ldap.ora file.

Check following setting whether they point to correct location of these files:

  1. data source alias in the dataSources section under <oracle.manageddataaccess.client> section in the .NET config file.
  2. data source alias in the tnsnames.ora file at the location specified by TNS_ADMIN in the .NET config file. Locations can consist of either absolute or relative directory paths.
  3. data source alias in the tnsnames.ora file present in the same directory as the .exe.

Note, unlike other providers ODP.NET Managed Provider does not read any Registry settings and does not read environment variable.

There have been a bug reported that ODP.NET Managed Provider does not resolve alias from LDAP, see this workaround: ODP.NET Managed library does resolve alias, but 32-bit library does

Community
  • 1
  • 1
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • Thank you for reply. I know what ODAC and ADO.NET are. If you look at my question again you will notice that I had no problem connecting with ADO.NET, but I wanted to use EF 6. Plus I use LDAP so tnsnames.ora is out of context for the discussion. Having said that I was able to connect to DB. However, at that point I am not sure how I can tell EF 6 Framework that I would like to use Database First Model (without having the ability to use EDM). I also saw Migration table in DB so for sure it is using Code First I believe. Thanks again for your input. – programmerboy Oct 05 '16 at 12:39
  • Well, actually the rule should be more precise saying "data source alias, resp. references in the `sqlnet.ora` and `tnsnames.ora` or `ldap.ora` files ..." – Wernfried Domscheit Oct 05 '16 at 15:16