.net ORACLE 和实体框架。错误:在配置中找不到指定的商店提供程序或无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7596850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 15:56:05  来源:igfitidea点击:

ORACLE and Entity Framework. Error:the specified store provider cannot be found in the configuration or is not valid

.netoracleentity-framework-4odp.net

提问by Yaya

In my project I am using oracle and entity framework together.Both of my machines my developer machine win7 and my server win2008r2 I installed oracle beta entity framework and .net 4.0 framework.

在我的项目中,我同时使用 oracle 和实体框架。我的机器我的开发者机器 win7 和我的服务器 win2008r2 我安装了 oracle beta 实体框架和 .net 4.0 框架。

However my projects works on local machine and does not work on server giving the error :

但是我的项目在本地机器上工作,在服务器上不起作用,给出错误:

the specified store provider cannot be found in the configuration or is not valid 
SystemArgumentException unable to find the requested .net Framework data provider ...

Anyone can help me ?

任何人都可以帮助我吗?

采纳答案by Yaya

in short: do not use ODAC .net drivers, instead use oracle client complete installation. modifying ODAC components may be a bit diffucilt. So install latest version of oracle client to all machines everything is well.

简而言之:不要使用ODAC .net 驱动程序,而是使用oracle 客户端完整安装。修改 ODAC 组件可能有点困难。所以在所有机器上安装最新版本的 oracle 客户端一切正常。

  • old answer - For both machines I installed first oracle data provider for .net and then oracle beta entity framework providers . So for both machines I have multiple oracle client instances.
  • 旧答案 - 对于两台机器,我首先为 .net 安装了 oracle 数据提供程序,然后安装了 oracle beta 实体框架提供程序。因此,对于两台机器,我都有多个 oracle 客户端实例。

In my development machine oracle beta entity framework is configured as default client. -I dont know when/how it changed/ who changed -

在我的开发机器中,oracle beta 实体框架被配置为默认客户端。-我不知道它何时/如何改变/谁改变了 -

In server default provider is still old odp.net .

在服务器默认提供程序仍然是旧的 odp.net 。

After changing the default provider at server to oracle beta entity framework provider it changed.

将服务器上的默认提供程序更改为 oracle beta 实体框架提供程序后,它发生了变化。

Thanks again.

再次感谢。

回答by Firedragon

In the Application Pool and Advanced Settings...

在应用程序池和高级设置中...

Have a look at the "Enable 32-Bit Applications" and see if it is enabled. It wasn't set on my Windows 7 64bit and I had the same issues.

查看“启用 32 位应用程序”并查看它是否已启用。它没有在我的 Windows 7 64 位上设置,我遇到了同样的问题。

I am guessing it might also be fixed by installing the 64bit ODAC but haven't tried that yet.

我猜它也可以通过安装 64 位 ODAC 来修复,但还没有尝试过。

回答by user3106510

I had this problem before. I followed these instructions then it solved: with windows 10 x64

我以前遇到过这个问题。我按照这些说明然后解决了:使用 windows 10 x64

1- Install Visual Studio 2015.

1- 安装 Visual Studio 2015。

2- Install ODAC from http://www.oracle.com/partners/campaign/utilsoft-086879.html.

2- 从http://www.oracle.com/partners/campaign/utilsoft-086879.html安装 ODAC 。

  1. install ODTforVS2015 from http://www.oracle.com/technetwork/topics/dotnet/downloads/odacmsidownload-2745497.html

  2. copy tnsnames file witch configured in step #2 and paste it to Network folder of destination installation of step #3.

  3. change C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Machine.config <system.Data>tag like this:

    <system.data>
    <DbProviderFactories>
        <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" />
    <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>
    </system.data>
    
  4. add this line in web.config for web app, or in App.config if it is console App. under <configurations> </configurations>tag (Under not inside).

    <system.data>
        <DbProviderFactories>
          <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>
    </system.data>
    
  1. http://www.oracle.com/technetwork/topics/dotnet/downloads/odacmsidownload-2745497.html安装 ODTforVS2015

  2. 复制在步骤 #2 中配置的 tnsnames 文件并将其粘贴到步骤 #3 的目标安装的网络文件夹中。

  3. 像这样更改 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Machine.config<system.Data>标记:

    <system.data>
    <DbProviderFactories>
        <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" />
    <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>
    </system.data>
    
  4. 在 web 应用程序的 web.config 中添加此行,如果是控制台应用程序,则在 App.config 中添加此行。<configurations> </configurations>标签下(下不在里面)。

    <system.data>
        <DbProviderFactories>
          <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>
    </system.data>
    

回答by Pushkar Shembekar

If you are getting this error in 2018 and you are using IIS Express like I am, you may want to check your .csproj settings and ensure that it is running under x64 bitness. (Right click you web application's csproj, go to "Web" tab, under the "Servers" section, change the bitness to x64).

如果您在 2018 年遇到此错误并且您像我一样使用 IIS Express,您可能需要检查您的 .csproj 设置并确保它在 x64 位下运行。(右键单击您的 Web 应用程序的 csproj,转到“Web”选项卡,在“服务器”部分下,将位数更改为 x64)。

回答by Kolathur

We were installing our application on a windows 2012 server and we were getting the same error, we tried to run the applications in the 32 bit mode , but results are same. we tried to get the list of DbProviderFactories installed in the machine by a console app and figured out that the ODP.net Managed Driver is missing. it finally worked when we ran the batch file we found

我们在 Windows 2012 服务器上安装我们的应用程序,但遇到了同样的错误,我们尝试在 32 位模式下运行应用程序,但结果相同。我们试图通过控制台应用程序获取机器中安装的 DbProviderFactories 列表,并发现 ODP.net 托管驱动程序丢失。当我们运行我们找到的批处理文件时,它终于起作用了