简体   繁体   English

ADO.NET提供程序“Oracle.ManagedDataAccess.Client”未在计算机或应用程序配置文件中注册,或者无法加载

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

I am using .NET4.5.1 , MVC5 , EF6 , with Oracle.ManagedDataAccess 4.121.1.0 and Oracle.ManagedDataAccess.EntityFramework 6.121.2.0 我使用.NET4.5.1MVC5EF6 ,与Oracle.ManagedDataAccess 4.121.1.0Oracle.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. 它失败了(在var result = ... ), Unable to find the requested .Net Framework Data Provider. It may not be installed. 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 = ). 当试图寻找 DbProviderFactories ,集合中没有任何内容( var factoryClasses = )。

However I do have installed 12c 4 (ODTwithODAC121024) and 11g (ODTwithODAC1120320_32bit), and have restarted machine. 但是我确实安装了12c 4(ODTwithODAC121024)和11g(ODTwithODAC1120320_32bit),并重新启动了机器。

Database is running on 11g and I can access it with PL/SQL developer 数据库在11g上运行,我可以使用PL/SQL developer访问它 在此输入图像描述

Web.config looks following: Web.config看起来如下:

<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 我的假设是因为Oracle没有在DbProviderFactories或某个地方注册而失败

How do I register Oracle in DbProviderFactories? 如何在DbProviderFactories中注册Oracle? Or if this is not the case what is wrong with my setup? 或者,如果不是这样,我的设置有什么问题?

I encountered this error when i updated Visual Studio 2017. The error can be resolved by reinstalling ODT for VS 2017: 我更新Visual Studio 2017时遇到此错误。可以通过重新安装VST for VS 2017来解决此错误:

1) Close Visual Studio. 1)关闭Visual Studio。

2) Uninstall the existing Oracle Developer Tools for Visual Studio 2017 from control Panel. 2)从控制面板卸载现有的适用于Visual Studio 2017的Oracle Developer Tools。

3) Install the latest one (ODTforVS2017_122011.exe) from the following link: 3)从以下链接安装最新的(ODTforVS2017_122011.exe):

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

4) Open visual studio and build solution.The error should not generate now. 4)打开visual studio并构建解决方案。现在不应生成错误。

Figured it out. 弄清楚了。

In my machine.config there was already 在我的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" />

and then it was repeated in my web.config which would silently fail to give out any providers. 然后它在我的web.config中重复,它将默默地无法给出任何提供者。 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. 我把它运行了。

I resolved this by adding ODP.NET (Oracle.ManagedDataAccess.EntityFramework 12c) from NuGet. 我通过从NuGet添加ODP.NET(Oracle.ManagedDataAccess.EntityFramework 12c)解决了这个问题。 I'm running VS2015 with EF 6.2.0. 我用EF 6.2.0运行VS2015。

我刚刚通过安装Visual Studio 2013的Oracle Developer工具(我安装的VS版本)ODTforVS2013_121025.exe解决了这个错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有实例框架提供程序用于ADO.NET Oracle.ManagedDataAccess.Client没有配置 - No Entity Framework Provider for ADO.NET Oracle.ManagedDataAccess.Client Without Config 找不到具有不变名称“Oracle.ManagedDataAccess.Client”的ADO.NET提供程序的实体框架提供程序 - No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.ManagedDataAccess.Client' 具有不变名称“MySql.Data.MySqlClient”的 ADO.NET 提供程序未在计算机或应用程序配置文件中注册 - The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file visual Studio 2015更新1未注册或无法加载Oracle ADO.NET提供程序 - visual studio 2015 update 1 Oracle ADO.NET provider is either not registered, or could not be loaded 错误175:具有不变名称“MySql.Data.MySqlClient”的ADO.NET提供程序未在计算机或应用程序配置文件中注册 - Error 175: The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file 具有不变名称“System.Data.SQLite.EF6”的 ADO.Net 提供程序未在机器或应用程序配置文件中注册 - The ADO.Net provider with Invariant name 'System.Data.SQLite.EF6' is not registered in the machine or application config file 具有不变名称“MySql.Data.MySqlClient”的 ADO.NET 提供程序未在机器或应用程序配置文件中注册 - The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registred in the machine or application config file 如何在EF 6提供程序配置文件中添加/激活“ Oracle.ManagedDataAccess.Client”? - How to Add/Activate “Oracle.ManagedDataAccess.Client” in the EF 6 provider config file? mvc .net ADO&gt; .NET提供程序未注册或无法加载 - mvc .net ADO>NET provider is either not registered or could not be loaded 如何用 web.config 部分替换 machine.config 的“oracle.manageddataaccess.client”部分 - How to replace the “oracle.manageddataaccess.client” section of machine.config with web.config section
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM