4

We're trying to use an Entity Framework Model-First approach with Oracle 11g and ODP.NET 11.2.0.3.20. We'd like to use EF 4.1 or EF 5.0 with DbContext.

Short version: Has anyone managed to do that?

Long version: On VS2010 and Entity Framework 4.0, everything works fine. I'm able to Generate Database from Model.

When I try it with EF 4.1 or EF 5.0, I always end up with an Object reference not set to an instance of an Object error message in Visual Studio:

enter image description here

I tried it the following ways:

  • Created a new EF 5.0 model in VS2012, set code generation workflow and templates to the Oracle stuff (Generate Oracle via T4 (TPT).xaml and SSDLToOracle.tt). Then I clicked on Generate Database from Model and chose a working Oracle connection, but Visual Studio just shows that error.
  • Created an EF 4.1 model in VS2012, same error.
  • Created an EF 4.1 model in VS2010, same error.
  • Tried a Database-First approach in EF 5.0 and EF 4.1, same error.

It only works if I'm using VS2010 and EF 4.0.

However, Oracle claims that it should work, see http://www.oracle.com/technetwork/topics/dotnet/downloads/install112030-1440546.html :

ODAC supports DbContext APIs.

Has anyone managed to use EF 4.1 or 5.0 with Oracle ODP.NET?

EDIT: Turns out it works fine on a 32-bit virtual machine. The problem is only there on my 64-bit Windows 7 machine.

Jonas Sourlier
  • 13,684
  • 16
  • 77
  • 148
  • About the "object ref error". Maybe you can use Visual studio 2012 with entity framework 5 Also, ensure you install dev tools for Oracle 12c if you are using VS 2012 –  Aug 22 '13 at 06:45
  • 1
    But I'm using Oracle 11g on the database server. Shouldn't I be using Oracle 11g dev tools then? – Jonas Sourlier Aug 22 '13 at 12:23
  • 1
    Try this. You have to install the ODAC 11.2 Release 5 and Oracle Developer Tools for Visual Studio (11.2.0.3.20). This will install the graphics tools on Visual Studio (wich is 32 bits). Later install the same ODAC version for 64 bits, which is only the runtime. Remember to copy the tnsnames file on the 64 bits installation. Not tried with Model Firs, but solved a few issues at our company – ssanga Jun 18 '14 at 21:38

1 Answers1

0

Just delete corresponding connectionstring from project config file. Then choose new connection (to Oracle database) and click to generate DDL.

Zheglov
  • 61
  • 8