Configuration issues with Oracle Instant Client and Entity Framework c# entity-framework odac oracle

Accepted Answer

Add a<remove … /> portion of the<DbProviderFactories> a web configuration element to eliminate any current Oracle providers. (Prior to the<add> )

<remove invariant ="Oracle.DataAccess.Client" />

4/2/2012 5:58:15 PM

Popular Answer

Here is my answer for Xcopy.

I published it at


and also

However, I believe I can upload my xml here without any formatting problems.

"packages.config" in Nuget

<?xml version="1.0" encoding="utf-8"?>
  <package id="CommonServiceLocator" version="1.0" targetFramework="net35" />
  <package id="EnterpriseLibrary.Common" version="5.0.505.0" targetFramework="net35" />
  <package id="EnterpriseLibrary.Data" version="5.0.505.0" targetFramework="net35" />
  <package id="EntLibContrib.Data.OdpNet" version="5.0.505.0" targetFramework="net35" />
  <package id="Unity" version="2.1.505.2" targetFramework="net35" />
  <package id="Unity.Interception" version="2.1.505.2" targetFramework="net35" />


Observe the<clear /> tag underneath. Since you never know what could be in the machine.config file, I decided it was preferable to clean them away even if they might not be required.

<?xml version="1.0" encoding="utf-8"?>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

  <dataConfiguration defaultDatabase="OracleMainConnectionString">


    <add name="OracleMainConnectionString"
         connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyOracleServerName)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MyServiceName)));User ID=MyUserName;Password=MyPassword;"
      providerName="Oracle.DataAccess.Client" />

    <add key="ExampleKey" value="ExampleValue" />

      <clear />
      <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description=".Net Framework Data Provider for Oracle" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <add name="EntLibContrib.Data.OdpNet" invariant="EntLibContrib.Data.OdpNet" description="EntLibContrib Data OdpNet Provider" type="EntLibContrib.Data.OdpNet.OracleDatabase, EntLibContrib.Data.OdpNet, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null" />


I'm doing my development on a Windows 7 x64 computer.

ODAC1120320Xcopy was downloaded (from

that which is:

Release 5 of ODAC 11.2 ( Download the latest XCopy update (September 11, 2012).

This zip file was unzipped.

I looked through my files and found these:

OraOps11w.dll, oci.dll, Oracle.DataAccess.dll, and orannzsbb11.dll

For my 3.5 Framework needs (I'm not yet on 4.0), please take note that wherever there were 2 files with the same name, I picked the "bin2.x" or "odp.net20bin" version.

I grabbed these files and placed them in the same directory as my.sln file.


I put all the aforementioned files in the



I referenced Oracle.DataAccess.dll by using "Add Reference" in the "MyConsoleApp.csproj" C# project. (Of course, this required navigating to "..ThirdPartyReferencesOracle").

To transfer the "extra" (also known as "accessory") files, I utilized a "Post Build Event."

In my post-build event, my lines were:

copy $(ProjectDir)..\ThirdPartyReferences\Oracle\oci.dll $(TargetDir)*.*
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\orannzsbb11.dll $(TargetDir)*.*
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\oraociei11.dll $(TargetDir)*.*
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\OraOps11w.dll $(TargetDir)*.*

Notably, the "Copy if Newer" from the URL instructions above is replaced with my post-build event.

Upon running my app, I encountered a few missing dll issues.

Remark: Within the assembly where your calls to the EnterpriseLibrary are located. You'll get "oeCannot locate Microsoft" for data items. Practices. Namespace SomethingSomething To make the issues go away, just keep adding references to the dlls that the aforementioned package.config will download.

Here is a particular example:

"Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

So I went and inserted a reference to: after running Nuget, of course, to get all the files.


That resolved the problems.

And here is my C# code: (Note that "select *" is only used in demos.)

    using System;
    using System.Data;
    using System.Data.Common;
    using Microsoft.Practices.EnterpriseLibrary.Data;
public IDataReader EmployeesGetAll()

    IDataReader returnReader = null;


        Database db = DatabaseFactory.CreateDatabase();
        DbCommand dbc = db.GetSqlStringCommand("SELECT * FROM ( SELECT * FROM TEMPLOYEE ) WHERE ROWNUM <= 25");
        returnReader = db.ExecuteReader(dbc);
        return returnReader;




And it succeeded.

I'm grateful.

ODP.NET is now, in my opinion, a "xcopy" deployment.

To be sure, I still need to test on a fresh computer.

But the day is coming to an end, so.


Additional Details:

The information above is accurate. But I ran into a catch. To test my code, I was utilizing a "Console Application."

It DEFAULTS to x86 when you create a new Console Application to Visual Studio.

Observed here:

EDIT: (Updated link)

Therefore, everything I had done stopped functioning when I applied all the setup, code, and other things to a real project (which was set to "Any CPU" on an x64 bit system).

I discovered this file on, ODAC1120320Xcopy, with a little fiddling. I then went through the same process as before, except this time I searched the unzipped files of the x64 zip file.

Every system is functional.

But the "x86" default behavior for a Console program confused me.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow