ODP。无法找到所请求的。NET框架数据提供程序

时间:2021-04-12 02:09:49

I am trying to develop an ASP.NET MVC 4.0 application using Oracle 11g Express and the .NET 4.0 framework. I can connect to the DB using the ODP.NET provider and can also generate my EDMX against the database. What I can't do is query the underlying DB using entity framework. When instantiating my DbContext using the connectionString Visual Studio generated, I get the following error:

我正在开发一个ASP。NET MVC 4.0应用程序使用Oracle 11g Express和。NET 4.0框架。我可以使用ODP连接到DB。NET提供程序,并可以根据数据库生成我的EDMX。我不能使用实体框架查询底层数据库。当使用生成的connectionString Visual Studio实例化我的DbContext时,我得到以下错误:

Unable to find the requested .Net Framework Data Provider. It may not be installed

无法找到请求的。net Framework数据提供程序。它可能不会被安装

However, it is installed because

然而,它的安装是因为

  1. I can see the dll in the GAC.
  2. 我可以在GAC中看到dll。
  3. It is mentioned in machine.config.
  4. 在machine.config中提到。
  5. It is referenced by my project.
  6. 我的项目引用了它。
  7. I actually use it to generate my EDMX from the database.
  8. 实际上,我使用它从数据库生成我的EDMX。
  9. I have verified that I am referencing the correct version (4.112.3.0) everywhere
  10. 我已经验证了我在任何地方都引用了正确的版本(4.112.3.0)

I am running the code locally on Cassini and my hardware is 32-Bit architecture, so I would assume I would only be able to use 32-Bit DLL's, so it's not an architecture problem.

我在Cassini上本地运行代码,我的硬件是32位架构,所以我假设我只能使用32位DLL,所以这不是架构问题。

The specific bit of code is as such:

具体的代码位如下:

public class MyContext : ObjectContext, IUnitOfWork
{
    public MyContext() 
    : base(ConfigurationManager
          .ConnectionStrings["OracleEntities"]
          .ConnectionString)//Connectionstring is verified
    {}
}

please help me before I leave everything, grow a beard and go live in the mountains somewhere.

在我离开之前,请帮助我,留胡子,到山里去住。

SOLUTION: Since I haven't seen any mention of the solution, I'll mention it here for future generations. Andrei Mikhalevich below asked about my connection string format and although I was scheptical, I went and had a look. This is what I saw:

解决方案:由于我没有看到任何关于解决方案的介绍,我将在这里向后代介绍它。Andrei Mikhalevich在下面询问我的连接字符串格式,尽管我是scheptical,我还是去查看了一下。这就是我看到的:

metadata=res://*/OracleModel.csdl|res://*/
OracleModel.ssdl|res://*/
OracleModel.msl;
provider=provider=Oracle.DataAccess.Client;
provider connection string="DATA SOURCE=localhost:1521;
PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx

Now, pay special attention to the line

现在,要特别注意这条线

provider=provider=Oracle.DataAccess.Client;

it should, in fact, read

事实上,它应该阅读

provider=Oracle.DataAccess.Client;

otherwise you're telling EF to use [provider.dll], which isn't a real thing. Also note that it seems that the providerName property of the connectionString element seems to have been overridden or ignored.

否则,您将告诉EF使用[provider]。那不是真的东西。还要注意,connectionString元素的providerName属性似乎被重写或忽略了。

UPDATE 2: If this STILL does not help, have a look at machine.config. You should see the following section:

更新2:如果这仍然没有帮助,请查看machine.config。你应参阅以下部分:

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

  <remove invariant="Oracle.DataAccess.Client" />

</DbProviderFactories>

If <remove invariant="Oracle.DataAccess.Client" /> is present, comment it out and try again, otherwise, if it's not there, put it in and try again.

如果 <删除不变量= " Oracle.DataAccess。客户端“ />已经存在,请注释并再次尝试,否则,如果不存在,请将其放入并再次尝试。

8 个解决方案

#1


1  

Try this connection string format:

尝试这种连接字符串格式:

Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

Check out connection string examples for Oracle db http://www.connectionstrings.com/oracle

查看Oracle db http://www.connectionstrings.com/oracle的连接字符串示例

#2


7  

For us it was 32 vs. 64 bit process.

对我们来说,这是一个32位与64位的过程。

The server is 64 bit. The ODP.NET (Oracle Client) installed is also 64 bit. Our application compiled with the Target platform "Any CPU" and "Prefer 32-bit" flag SET:

服务器是64位的。ODP。NET (Oracle客户端)的安装也是64位的。我们的应用程序使用目标平台“任何CPU”和“更喜欢32位”的标志集编译:

http://grab.by/v5ki

http://grab.by/v5ki

was running as 32 bit process. Once recompiled with the flag un-checked everything started to work.

运行为32位进程。重新编译标志后,未检查的一切都开始工作。

#3


3  

I got the same error when opening the page via IIS, 64bit Win7.

我在通过iis64bit Win7打开页面时也有同样的错误。

My solution is:

我的解决方案是:

Go to IIS manager --> Application Pool --> Advanced Settings --> Enable 32-Bit Applications.

转到IIS管理器——>应用程序池——>高级设置——>支持32位应用程序。

ODP。无法找到所请求的。NET框架数据提供程序

#4


2  

This error is a little misleading because it can also be caused by running under the wrong CPU contexts. Make sure you are allowing for 32-bit if using a 32-bit Oracle driver. This can be done as a setting under IIS or you can setup your application to run as an IIS Express application.

这个错误有点误导人,因为它也可能是在错误的CPU上下文中运行造成的。如果使用32位Oracle驱动程序,请确保允许使用32位。这可以作为IIS下的设置完成,也可以将应用程序设置为IIS Express应用程序运行。

#5


2  

I had a similar problem. It was resolved by adding a NuGet package. I already had Oracle.ManagedDataAccess.EntityFramework available in my references from the install of ODT but it was giving an Entity Framework 5 conflict with 6 in the detailed log. Once I added the NuGet package, everything started working.

我也有类似的问题。通过添加NuGet包解决了这个问题。我已经有了Oracle.ManagedDataAccess。EntityFramework可以从ODT的安装中获得,但是它提供了一个实体框架5与详细日志中的6冲突。一旦我添加了NuGet包,一切都开始工作了。

  • To install, right click References --> Manage NuGet Packages… --> Search for Oracle in the Browse tab --> Choose Oracle.ManagedDataAccess.EntityFramework and install the latest version.
  • 要安装,右键单击引用——>管理NuGet包……——>在Browse选项卡中搜索Oracle——>选择Oracle.ManagedDataAccess。EntityFramework并安装最新版本。

#6


1  

Another possible solution for someone out there.

另一个可能的解决方案。

My webapp was working well on my test server but when I started to develop for my live server I got the same error: Unable to find the requested .Net Framework Data Provider. It may not be installed

我的webapp在我的测试服务器上运行得很好,但是当我开始为我的live服务器开发时,我得到了同样的错误:无法找到请求的。net Framework数据提供程序。它可能不会被安装

If you compare the two connection strings below you will notice that the one causing my issue had the "Managed" word in the provider name. I'm actually using the unmanaged version of the Oracle provider. Hence I was getting the error on my live server and not on my test server.

如果您比较下面的两个连接字符串,您将注意到引起我的问题的那个字符串在提供程序名称中有“Managed”字。实际上,我使用的是Oracle提供程序的非托管版本。因此,我在我的实时服务器上而不是在我的测试服务器上获得错误。

    **ORIGINAL:**
    connectionString="DATA SOURCE=192.168.10.101:1521/dataconn;PASSWORD=password;PERSIST   SECURITY INFO=True;USER ID=DataConn" providerName="Oracle.ManagedDataAccess.Client"


    **NEW:**
    connectionString="DATA SOURCE=192.168.10.101:1521/dataconn;PASSWORD=password;PERSIST     SECURITY INFO=True;USER ID=DataConn" providerName="Oracle.DataAccess.Client"

#7


1  

Here is what worked for me. My server already had an Oracle client installed. (version 11.2.0)

这是对我有用的。我的服务器已经安装了Oracle客户端。(11.2.0版)

  • Download from the ODAC for Windows Downloads page the ODP.NET Managed Driver
    (I chose the Oct. 2015 release, 2.43 MB download)

    从ODAC下载到Windows下载页面ODP。NET托管驱动(我选择了2015年10月的版本,2.43 MB下载)

  • Extract the zip file, grab the \lib\net40\Oracle.ManagedDataAccess.dll, and place it in the bin folder.

    解压zip文件,获取\lib\net40\Oracle.ManagedDataAccess。dll文件,并将其放在bin文件夹中。

  • In the web.config, add a reference to the ODP.NET Managed Driver under system.data\DbProviderFactories explained in this answer.

    在web。配置,添加对ODP的引用。系统下的NET管理驱动程序。在这个答案中解释了data\DbProviderFactories。

That's it.

就是这样。

To confirm, run this answer's code to see if the ODP.NET provider is installed. You should see ODP.NET, Managed Driver in the list.

要确认,请运行此答案的代码以查看ODP。净提供者安装。您应该看到ODP。NET,列表中的托管驱动程序。

#8


0  

I actually downloaded the ODAC and install it. Then I Add a Reference and found the package roadrunner71 mentioned.

我下载了ODAC并安装了它。然后我添加了一个参考,找到了前面提到的package roadrunner71。

#1


1  

Try this connection string format:

尝试这种连接字符串格式:

Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

Check out connection string examples for Oracle db http://www.connectionstrings.com/oracle

查看Oracle db http://www.connectionstrings.com/oracle的连接字符串示例

#2


7  

For us it was 32 vs. 64 bit process.

对我们来说,这是一个32位与64位的过程。

The server is 64 bit. The ODP.NET (Oracle Client) installed is also 64 bit. Our application compiled with the Target platform "Any CPU" and "Prefer 32-bit" flag SET:

服务器是64位的。ODP。NET (Oracle客户端)的安装也是64位的。我们的应用程序使用目标平台“任何CPU”和“更喜欢32位”的标志集编译:

http://grab.by/v5ki

http://grab.by/v5ki

was running as 32 bit process. Once recompiled with the flag un-checked everything started to work.

运行为32位进程。重新编译标志后,未检查的一切都开始工作。

#3


3  

I got the same error when opening the page via IIS, 64bit Win7.

我在通过iis64bit Win7打开页面时也有同样的错误。

My solution is:

我的解决方案是:

Go to IIS manager --> Application Pool --> Advanced Settings --> Enable 32-Bit Applications.

转到IIS管理器——>应用程序池——>高级设置——>支持32位应用程序。

ODP。无法找到所请求的。NET框架数据提供程序

#4


2  

This error is a little misleading because it can also be caused by running under the wrong CPU contexts. Make sure you are allowing for 32-bit if using a 32-bit Oracle driver. This can be done as a setting under IIS or you can setup your application to run as an IIS Express application.

这个错误有点误导人,因为它也可能是在错误的CPU上下文中运行造成的。如果使用32位Oracle驱动程序,请确保允许使用32位。这可以作为IIS下的设置完成,也可以将应用程序设置为IIS Express应用程序运行。

#5


2  

I had a similar problem. It was resolved by adding a NuGet package. I already had Oracle.ManagedDataAccess.EntityFramework available in my references from the install of ODT but it was giving an Entity Framework 5 conflict with 6 in the detailed log. Once I added the NuGet package, everything started working.

我也有类似的问题。通过添加NuGet包解决了这个问题。我已经有了Oracle.ManagedDataAccess。EntityFramework可以从ODT的安装中获得,但是它提供了一个实体框架5与详细日志中的6冲突。一旦我添加了NuGet包,一切都开始工作了。

  • To install, right click References --> Manage NuGet Packages… --> Search for Oracle in the Browse tab --> Choose Oracle.ManagedDataAccess.EntityFramework and install the latest version.
  • 要安装,右键单击引用——>管理NuGet包……——>在Browse选项卡中搜索Oracle——>选择Oracle.ManagedDataAccess。EntityFramework并安装最新版本。

#6


1  

Another possible solution for someone out there.

另一个可能的解决方案。

My webapp was working well on my test server but when I started to develop for my live server I got the same error: Unable to find the requested .Net Framework Data Provider. It may not be installed

我的webapp在我的测试服务器上运行得很好,但是当我开始为我的live服务器开发时,我得到了同样的错误:无法找到请求的。net Framework数据提供程序。它可能不会被安装

If you compare the two connection strings below you will notice that the one causing my issue had the "Managed" word in the provider name. I'm actually using the unmanaged version of the Oracle provider. Hence I was getting the error on my live server and not on my test server.

如果您比较下面的两个连接字符串,您将注意到引起我的问题的那个字符串在提供程序名称中有“Managed”字。实际上,我使用的是Oracle提供程序的非托管版本。因此,我在我的实时服务器上而不是在我的测试服务器上获得错误。

    **ORIGINAL:**
    connectionString="DATA SOURCE=192.168.10.101:1521/dataconn;PASSWORD=password;PERSIST   SECURITY INFO=True;USER ID=DataConn" providerName="Oracle.ManagedDataAccess.Client"


    **NEW:**
    connectionString="DATA SOURCE=192.168.10.101:1521/dataconn;PASSWORD=password;PERSIST     SECURITY INFO=True;USER ID=DataConn" providerName="Oracle.DataAccess.Client"

#7


1  

Here is what worked for me. My server already had an Oracle client installed. (version 11.2.0)

这是对我有用的。我的服务器已经安装了Oracle客户端。(11.2.0版)

  • Download from the ODAC for Windows Downloads page the ODP.NET Managed Driver
    (I chose the Oct. 2015 release, 2.43 MB download)

    从ODAC下载到Windows下载页面ODP。NET托管驱动(我选择了2015年10月的版本,2.43 MB下载)

  • Extract the zip file, grab the \lib\net40\Oracle.ManagedDataAccess.dll, and place it in the bin folder.

    解压zip文件,获取\lib\net40\Oracle.ManagedDataAccess。dll文件,并将其放在bin文件夹中。

  • In the web.config, add a reference to the ODP.NET Managed Driver under system.data\DbProviderFactories explained in this answer.

    在web。配置,添加对ODP的引用。系统下的NET管理驱动程序。在这个答案中解释了data\DbProviderFactories。

That's it.

就是这样。

To confirm, run this answer's code to see if the ODP.NET provider is installed. You should see ODP.NET, Managed Driver in the list.

要确认,请运行此答案的代码以查看ODP。净提供者安装。您应该看到ODP。NET,列表中的托管驱动程序。

#8


0  

I actually downloaded the ODAC and install it. Then I Add a Reference and found the package roadrunner71 mentioned.

我下载了ODAC并安装了它。然后我添加了一个参考,找到了前面提到的package roadrunner71。