Entity Framework 6 (5) connection to Oracle

25,918

Solution 1

EF 6 support is now provided by ODAC 12c Release 3 Beta:

From the .Net Developer newsletter (emphasis mine):

New Download: ODAC 12c Release 3 Beta The new ODAC beta includes Entity Framework 6, Code First, Code First Migrations, .NET Framework 4.5.2 certification, managed ODP.NET XML DB, and managed ODP.NET distributed transaction support without Oracle.ManagedDataAccessDTC.dll.

Solution 2

I know this is getting a little old, but this is to answer the last part of your question (how to install EFv5). (Instructions written for VisualStudio 2013) with your solution open, click TOOLS->NuGet Package Manager->Package Manager Console. Enter the following:

Install-Package EntityFramework -Version 5.0.0

Edit

It’s been a while since I set up my machine, but I think this is what I had to do, hopefully it helps.

Setup:

  1. Install Oracle Instant Client (or whatever you do for an Oracle Home)
  2. Install ODTwithODAC121012 (if you Google that, it should come up)
  3. Make sure your tnsnames.ora is in the right place for your Oracle Home

Setting up a new Visual Studio Solution:

  1. New Solution (for me, of type ASP.NET Web Application)
  2. Run command as in original answer
  3. Add new project of type Class Library (for Model/Entities)
  4. In new project, add new Item of type ADO.NET Entity Data Model
  5. In Entity Data Model Wizard:
    1. EF Designer from database (if you are using an existing database)
    2. New Connection
    3. In Data Source, there is (hopefully) an Oracle Database option
    4. And below that, in data provider, I chose the ODP.NET Managed Driver
    5. Enter user/pass, select Data Source and name connection

Edit 2

Oh, I forgot one thing, not sure if it's important. You may need to add a reference in that Model project to the oracle driver. Right click project -> Add -> Reference -> Assemblies -> Search for 'oracle', hopefully there is an entry for Oracle.ManagedDataAccess (my version was 4.121.1.0)

A few rants:

  1. I don't think the process should be quite so difficult
  2. I don't know why it takes them so long to update either. http://www.devart.com/ seems to do just fine staying on top of new Oracle/Visual Studio changes (they charge, but so does Oracle)
  3. The conspiracy part of my brain says that Oracle has no interest in making it easier for you to not use their products and so they put no effort into it
  4. Their default number mappings can really screw you up. For example, if your Oracle DB has fields of type NUMBER(10), it will map it as a 32-bit int, when not all 10 digit numbers fit :(
  5. For more info on that mapping thing (the link shows how to override that 32-bit problem), see: http://docs.oracle.com/cd/E56485_01/win.121/e55744/InstallConfig.htm#ODPNT8167

Solution 3

EF 6 is not yet supported by ODP.NET. See the release notes (README) for more info. EF6 will be supported shortly.

Edit: EF6 is now supported.

Solution 4

Sorry, I missed part of your question.

If you are using Visual Studio 2013, you must download Oracle Developer Tools for Visual Studio version 12.1.0.1.2 or later. With any older version, it will not be able to integrate with VS 2013.

Here is the download location: http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

EF 6.0 is not supported yet but you can use EF5 providers in VS 2013. So my other answer is not really relevant.

Share:
25,918
SoftwareSavant
Author by

SoftwareSavant

Software developer 8 years of Software Development experience Have held jobs writing: Java, .Net Code (C#, VB), Javascript (React.js, JQuery) and PHP MSSQL Server queries, views, stored procs and some table design Oracle 10g queries, views, stored procs... No database design experience using Oracle. Prior to my positions in development held jobs on a helpdesk level and on network engineering basis (real simple stuff there)... using System.Web.TehForums; public static void main(string[] args) { System.Console.WriteLine("Hello World"); }

Updated on July 15, 2022

Comments

  • SoftwareSavant
    SoftwareSavant almost 2 years

    I am attempting to write a Data Access library for our suite of applications that use Oracle in .net. We currently use NHibernate and are thinking of migrating away as it appears to not be supported all that well.

    I am working with Visual Studio 2013 and we have already constructed our Oracle Database. We don't have writes to update it (that is the domain of the db guys). So that will not be part of any calculation on our end.

    The client on the server is 32 bit, so we are going to stick with that for now. It is already GAC'd in there, and no need to change it. So we have the 32 bit client on our development boxes.

    I have EntityFramework 6.1.0 installed into my project via nuget. I have ODAC 1.112.3.20 installed in my project. The 32bit version of the application. I also have the ODP.net.x86 driver installed (also via nuget).

    The problem is that everytime I attempt to create an ADO.net Database connection, the oracle provider is never an option? What am I missing? What do I need to get this to work?

    I read an oracle forum one time that said I need to set my Entity Framework to 5.0 and not 6.0. Which is fine, but how do I do that?