ODP.NET Managed - Unable to find requested .Net Framework Data Provider

user1077685 picture user1077685 · Aug 19, 2014 · Viewed 25.3k times · Source

Using Visual Studio 2013, I've added the latest version of ODP.NET Managed to a project using Nuget:

Install-Package odp.net.managed

http://www.nuget.org/packages/odp.net.managed/121.1.2

Now, when I try to run the following code:

Database db = DatabaseFactory.CreateDatabase();

It throws the following exception:

An exception of type 'System.ArgumentException' occurred 
in System.Data.dll but was not handled in user code
Additional information: Unable to find the requested .Net
Framework Data Provider.  It may not be installed.

After reading of other users's similar issues, I added the Managed driver section to C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Config\machine.config:

<system.data>
        <DbProviderFactories><add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
    </system.data>

But that had no affect.

I have the connection string specified as such in my web.config, but I'm not sure if it is even looking at the connection string format as it is failing before I open the connection:

<connectionStrings>
    <add name="OneCDPBuild" 
    providerName="Oracle.ManagedDataAccess.Client" 
    connectionString="Data Source=database;user id=IDhere;pwd=passwordhere;" />
  </connectionStrings>

I added the following to my web config:

<system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <add name="ODP.NET, Managed Driver"
           invariant="Oracle.ManagedDataAccess.Client"
           description="Oracle Data Provider for .NET, Managed Driver"
           type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>

Answer

Yves Rochon picture Yves Rochon · Sep 25, 2014

I was getting this error when deploying an ASP.NET MVC 5 application using EntityFramework 5 to our 64-bit server on which the 64-bit version of the ODAC client components were installed.

I followed b_levitt's advise and confirmed that the connection could be opened manually without using the factories, so the ODAC was installed and working, but the factory methods were unable to locate the assemblies.

After pulling my hair for an undisclosed amount of time, I figured out that the problem was with the machine.config file for the 32-bit version of the .NET framework. It did not include the entries for the oracle providers, so I manually added the following entries to this file:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

Under

<configuration>
  <configSections>

make sure that you have the following two section entires:

<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

You can get the exact entries from your machine.config file under the framework64 folder.

Next, under

  <system.data>
    <DbProviderFactories>

make sure that you have the following two factory names:

  <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  <add name="ODP.NET, Unmanaged Driver" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET, Unmanaged Driver" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

After adding these entries, everything was working for me.