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

查看:64
本文介绍了ADO.NET提供程序' Oracle.ManagedDataAccess.Client'未在计算机或应用程序配置文件中注册,或者无法加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 .NET4.5.1 MVC5 EF6 Oracle.ManagedDataAccess 4.121.1.0 一起使用和 Oracle.ManagedDataAccess.EntityFramework 6.121.2.0

我能够从现有数据库生成模型(模型的一部分逐表添加),应用程序构建就很好.

但是,当我尝试运行测试查询以查看它是否可以获取数据时

 公共ActionResult Cancellations(){var factoryClasses = System.Data.Common.DbProviderFactories.GetFactoryClasses();使用(var db = new Entities()){var cancelationStatuses = new [] {3,7,9};var result = db.TRANSACTIONDETAIL.Where(o => cancelationStatuses.Contains(o.TRANSACTIONSTATUSID));返回View(result);}} 

它失败(在 var结果= ... 上),并且找不到所需的.Net Framework数据提供程序.可能未安装.

Web.config看起来如下:

 < configuration>< configSections><!-有关Entity Framework配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468-><节名称="entityFramework" type ="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089" requirePermission ="false"/><节名称="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 =用户ID = oracle_user;密码= oracle_user_password;数据源= oracle"/><添加名称=实体" connectionString ="metadata = res://*/OracleDb.csdl | res://*/OracleDb.ssdl | res://*/OracleDb.msl; provider = Oracle.ManagedDataAccess.Client; provider connection string ='数据源= ******"providerName =" System.Data.EntityClient"/></connectionStrings>......< system.data>< DbProviderFactories><!-如果已在machine.config中定义,请删除-->< add name =.NET的Oracle数据提供程序" invariant ="Oracle.ManagedDataAccess.Client" description =.NET的Oracle数据提供程序" type ="Oracle.ManagedDataAccess.Client.OracleClientFactory,Oracle.ManagedDataAccess,Version = 4.121.1.0,Culture = neutral,PublicKeyToken = 89b483f429c47342"/><删除invariant ="Oracle.ManagedDataAccess.Client"/><添加名称="ODP.NET,托管驱动程序" invariant ="Oracle.ManagedDataAccess.Client" description =.NET的Oracle数据提供程序,托管驱动程序" type ="Oracle.ManagedDataAccess.Client.OracleClientFactory,Oracle.ManagedDataAccess,版本= 4.121.2.0,文化=中性,PublicKeyToken = 89b483f429c47342"/></DbProviderFactories> 

我的假设失败了,因为Oracle没有在 DbProviderFactories 或某处注册

如何在DbProviderFactories中注册Oracle?还是如果不是这种情况,我的设置有什么问题?

解决方案

更新Visual Studio 2017时遇到此错误.可以通过重新安装VS 2017的ODT来解决该错误:

1)关闭Visual Studio.

2)从控制面板中卸载现有的适用于Visual Studio 2017的Oracle开发人员工具.

3)通过以下链接安装最新版本(ODTforVS2017_122011.exe):

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

4)打开Visual Studio并构建解决方案.该错误现在不应该产生.

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

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?

解决方案

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.

这篇关于ADO.NET提供程序&amp;#39; Oracle.ManagedDataAccess.Client&amp;#39;未在计算机或应用程序配置文件中注册,或者无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆