The ADO.NET provider 'Oracle.ManagedDataAccess.Client' is either not registered in the machine or application config file, or could not be loaded

52,146

Solution 1

I encountered this error when i updated Visual Studio 2017. The error can be resolved by reinstalling ODT for VS 2017:

1) Close Visual Studio.

2) Uninstall the existing Oracle Developer Tools for Visual Studio 2017 from control Panel.

3) Install the latest one (ODTforVS2017_122011.exe) from the following link:

http://www.oracle.com/technetwork/topics/dotnet/downloads/odacmsidownloadvs2017-3806459.html

4) Open visual studio and build solution.The error should not generate now.

Solution 2

Figured it out.

In my machine.config there was already

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

and then it was repeated in my web.config which would silently fail to give out any providers. So after taking out:

  <add name="Oracle Data Provider for .NET" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  <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.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

I got it running.

Solution 3

I resolved this by adding ODP.NET (Oracle.ManagedDataAccess.EntityFramework 12c) from NuGet. I'm running VS2015 with EF 6.2.0.

Solution 4

I just resolved this error by installing Oracle Developer tool for visual studio 2013 (my installed VS version) ODTforVS2013_121025.exe

Share:
52,146
Matas Vaitkevicius
Author by

Matas Vaitkevicius

In Javascript Let me take a selfie... var self = this; #SOreadytohelp Like my answer, here's link for donations. https://www.paypal.me/Vaitkevicius

Updated on May 10, 2020

Comments

  • Matas Vaitkevicius
    Matas Vaitkevicius about 4 years

    I am using .NET4.5.1, MVC5, EF6, with Oracle.ManagedDataAccess 4.121.1.0 and Oracle.ManagedDataAccess.EntityFramework 6.121.2.0

    I was able to generate Model from existing database (part of it adding table by table), application builds just fine.

    However when I try run test query to see if it can get the data

     public ActionResult Cancellations()
        {
            var factoryClasses = System.Data.Common.DbProviderFactories.GetFactoryClasses();
            using (var db = new Entities())
            {
                var cancelationStatuses = new[] {3, 7, 9};
               var result = db.TRANSACTIONDETAIL.Where(o => cancelationStatuses.Contains(o.TRANSACTIONSTATUSID));
               return View(result);
            }
        }
    

    it fails (on var result = ...) with Unable to find the requested .Net Framework Data Provider. It may not be installed.

    When trying to look for DbProviderFactories indeed there is nothing in collection (var factoryClasses =).

    However I do have installed 12c 4 (ODTwithODAC121024) and 11g (ODTwithODAC1120320_32bit), and have restarted machine.

    Database is running on 11g and I can access it with PL/SQL developer enter image description here

    Web.config looks following:

    <configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     <section name="Oracle.ManagedDataAccess.Client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </configSections>
    .....
    <connectionStrings>
    .....
    <add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=oracle_user;Password=oracle_user_password;Data Source=oracle" />
     <add name="Entities" connectionString="metadata=res://*/OracleDb.csdl|res://*/OracleDb.ssdl|res://*/OracleDb.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string='data source=******" providerName="System.Data.EntityClient" />           </connectionStrings>
    ......
    <system.data>
    <DbProviderFactories>
      <!-- Remove in case this is already defined in machine.config -->
      <add name="Oracle Data Provider for .NET" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <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.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
    

    My assumption it's failing because Oracle is not being registered in DbProviderFactories or somewhere

    How do I register Oracle in DbProviderFactories? Or if this is not the case what is wrong with my setup?

  • Farid Imranov
    Farid Imranov over 5 years
    This was solution for me. Thank you dude!
  • neilsimp1
    neilsimp1 over 5 years
    This was the fix for me as well, ODTforVS2017 version 18.3.0
  • Furkan Ekinci
    Furkan Ekinci almost 5 years
    I tried it firstly because of this looks quicker then removing "Oracle Developer Tools for Visual Studio 2017" answer but it doesn't worked for me, then I removed Oracle Developer Tools for Visual Studio 2017 and reinstalled, it worked.
  • Roger Perkins
    Roger Perkins about 2 years