带有实体框架 6 的 Oracle ODP.Net - 找不到与实体框架数据库兼容的提供程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27656519/
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
Oracle ODP.Net With Entity Framework 6 - Entity framework database compatible provider could not be found
提问by Wasef Anabtawi
I am trying to build an MVC 5 Web application with Entity Framework 6 that works on Oracle Database , am trying to use ODAC 12c Release 3 which includes support for Entity Framework 6 Code First and Code First Migrations; NuGet, .NET Framework 4.5.2; and ODP.NET, Managed Driver XML DB. As per
我正在尝试使用适用于 Oracle 数据库的 Entity Framework 6 构建 MVC 5 Web 应用程序,我正在尝试使用 ODAC 12c 第 3 版,其中包括对实体框架 6 代码优先和代码优先迁移的支持;NuGet,.NET 框架 4.5.2;和 ODP.NET,托管驱动程序 XML DB。按照
http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html
http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html
I have VS 2013 Community Edition update 4 .
我有 VS 2013 社区版更新 4 。
Am trying to add Model using ADO.Net Entity Data Model , With Code First.
我正在尝试使用 ADO.Net 实体数据模型添加模型,代码优先。
I have the following configured in my Web.config
我在我的 Web.config 中配置了以下内容
<configSections>
<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.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<entityFramework>
<contexts>
<context type="Tamayz.Context.Default, Tamayz.Context">
<databaseInitializer type="MyProject.Context.Config.ContextInitializer, MyProject.Context" />
</context>
</contexts>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client"
type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</providers>
</entityFramework>
I also added Oracle.ManagedDataAccess version 4.121.2.0 as a reference and rebuild the solution.
我还添加了 Oracle.ManagedDataAccess 版本 4.121.2.0 作为参考并重建解决方案。
I tried now to add Model using ADO.Net Entity Data Model , With Code First. but am getting the following message in the last screen of the wizard:
我现在尝试使用 ADO.Net 实体数据模型添加模型,代码优先。但在向导的最后一个屏幕中收到以下消息:
Your project references that latest version of entity framework; however, an Entity Framework database Provider compatible with this version could not be found for your connection...
您的项目引用了最新版本的实体框架;但是,无法为您的连接找到与此版本兼容的实体框架数据库提供程序...
How could I properly configure my application to be able to use ODAC with EF6 Code first ?
我如何正确配置我的应用程序,以便能够首先将 ODAC 与 EF6 代码一起使用?
回答by Wasef Anabtawi
I finally was able to to use ODP with EF6.
我终于能够在 EF6 中使用 ODP。
I did the following to make it work :-
我做了以下工作以使其正常工作:-
First Installing ODAC 12c Release 3 which includes support for Entity Framework 6 Code First and Code First Migrations; NuGet, .NET Framework 4.5.2; and ODP.NET, Managed Driver XML DB. As per
首先安装 ODAC 12c 第 3 版,其中包括对实体框架 6 代码优先和代码优先迁移的支持;NuGet,.NET 框架 4.5.2;和 ODP.NET,托管驱动程序 XML DB。按照
http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html
http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html
Adding two references , to my project references and they are :
在我的项目引用中添加两个引用,它们是:
Oracle.ManagedDataAccess.dll
Oracle.ManagedDataAccess.dll
Oracle.ManagedDataAccess.EntityFramework.dll
Oracle.ManagedDataAccess.EntityFramework.dll
Installing EF6.1.1 using NuGet by running the following command in Package Manager Console( you can enter it by Tools->NuGet Package Manager -> Package Manager Console):
通过在包管理器控制台中运行以下命令使用 NuGet 安装 EF6.1.1(您可以通过工具->NuGet 包管理器 -> 包管理器控制台输入):
Install-Package EntityFramework -Version 6.1.1
And modify your web.config or web.config to use Oracle.ManagedDataAccess , by adding Provider and a valid connection string eg :
并通过添加 Provider 和有效的连接字符串修改您的 web.config 或 web.config 以使用 Oracle.ManagedDataAccess ,例如:
<configSections>
<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" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<contexts>
<context type="App.Context.Default, App.Context">
<databaseInitializer type="MyProject.Context.Config.ContextInitializer, MyProject.Context" />
</context>
</contexts>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="Default" providerName="Oracle.ManagedDataAccess.Client" connectionString="DATA SOURCE=XE;USER ID=User" />
</connectionStrings>
Rebuild your Application as x86, and start using EF6 , you can check if it works by adding a model using ADO.Net Entity Model using Code First
将您的应用程序重建为 x86,并开始使用 EF6 ,您可以通过使用 Code First 添加使用 ADO.Net 实体模型的模型来检查它是否有效
回答by Fernando Meneses Gomes
Just to complement, i've tried everything but in my case it was solved by setting the "defaultConnectionFactory", like this:
只是为了补充,我已经尝试了所有方法,但在我的情况下,它是通过设置“ defaultConnectionFactory”来解决的,如下所示:
<entityFramework>
<defaultConnectionFactory type="Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory, Oracle.ManagedDataAccess.EntityFramework">
</defaultConnectionFactory>
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</providers>
</entityFramework>
found the solution here: https://community.oracle.com/message/13114643#13114643
在这里找到了解决方案:https: //community.oracle.com/message/13114643#13114643
I hope it helps someone...
我希望它可以帮助某人...
回答by chakeda
I tried everything in the selected answer but I couldn't create my models. I had the same issue as @WAQ in the comments of the selected answer, where I didn't get the error message but it skipped to the table selection.
我尝试了所选答案中的所有内容,但无法创建模型。我在所选答案的评论中遇到了与@WAQ 相同的问题,我没有收到错误消息,但它跳到了表选择。
I'm using VS2017 15.7.4, Oracle 12g, and EF 6.1.1.
我使用的是 VS2017 15.7.4、Oracle 12g 和 EF 6.1.1。
I decided to downgrade Oracle.ManagedDataAccess.EntityFrameworkand Oracle.ManagedDataAccessfrom 18.3.0 to 12.2.1100 and it finally worked!
我决定降级Oracle.ManagedDataAccess.EntityFramework并Oracle.ManagedDataAccess从 18.3.0降级到 12.2.1100 终于成功了!
回答by Andy Midd
I also downgraded to 6.1.2 and all my problems with adding an Entity Model disappeared. It seems both 2015 and 2017 Visual Studio have problems with versions any higher than that. Oracle need to look at this ASAP.
我也降级到 6.1.2,我添加实体模型的所有问题都消失了。似乎 2015 年和 2017 年的 Visual Studio 都存在高于此版本的问题。Oracle 需要尽快查看此问题。
回答by Asier Azkuenaga
I just had this problem on visual studio 2015. In my case it was due to Entity Framework 6.1.3 not being supported. After downgrading it to 6.1.2 it's working.
我刚刚在 Visual Studio 2015 上遇到了这个问题。就我而言,这是由于不支持 Entity Framework 6.1.3。将其降级到 6.1.2 后,它就可以工作了。
回答by XDS
Late joining to this thread. A couple of folks upgraded to VS2017 (the rest in our team are still using VS2015 and planning to upgrade to VS2017). One of our projects was referencing Oracle.ManagedDataAccess.dll ver4.121.2.0 & Oracle.ManagedDataAccess.EntityFramework.dll ver6.121.2.0 via locally-referenced dlls.
迟到加入这个线程。有几个人升级到了 VS2017(我们团队中的其他人仍在使用 VS2015 并计划升级到 VS2017)。我们的一个项目是通过本地引用的 dll 引用 Oracle.ManagedDataAccess.dll ver4.121.2.0 和 Oracle.ManagedDataAccess.EntityFramework.dll ver6.121.2.0。
All dev-workstations had oracle-odac-drivers ver4.122.1.0 & ver6.122.1.0 installed system-wide (GAC etc).
所有开发工作站都在系统范围内(GAC 等)安装了 oracle-odac-drivers ver4.122.1.0 和 ver6.122.1.0。
This kind of setup was working just fine for VS2015 but for some weird reason it was not working for VS2017. The culprit for VS2017 was that the Oracle.ManagedDataAccess.dll & Oracle.ManagedDataAccess.EntityFramework.dll where not getting copied over to the output folder of our entry-level asp.net project unless and until the locally referenced dlls where also updated to ver4.121.2.0 & ver6.121.2.0.
这种设置在 VS2015 上工作得很好,但由于一些奇怪的原因,它不适用于 VS2017。VS2017 的罪魁祸首是 Oracle.ManagedDataAccess.dll 和 Oracle.ManagedDataAccess.EntityFramework.dll 没有被复制到我们入门级 asp.net 项目的输出文件夹,除非本地引用的 dll 也更新到 ver4 .121.2.0 & ver6.121.2.0。
We didn't have time to look any further into all this but the aforementioned solution worked for VS2017.
我们没有时间深入研究这一切,但上述解决方案适用于 VS2017。
回答by Syaiful Nizam Yahya
For me, installing this Nuget packages works. https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/
对我来说,安装这个 Nuget 包是有效的。 https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/
回答by toha
My Computer :Win 7 64 bit
我的电脑:Win 7 64 位
VS 2015
VS 2015
Oracle Server :
甲骨文服务器:
version 12G - 32 bit
版本 12G - 32 位
What I have tried until success :
我尝试过的直到成功:
-downgrade Oracle.ManagedDataAccess.EntityFramework and Oracle.ManagedDataAccess from 18.3.0 to 12.2.20190115
-将 Oracle.ManagedDataAccess.EntityFramework 和 Oracle.ManagedDataAccess 从 18.3.0 降级到 12.2.20190115
-Change Build mode from Any CPU to x86
- 将构建模式从任何 CPU 更改为 x86
-Configuration app.config:
-配置app.config:
<configSections>
<section name="Oracle.ManagedDataAccess.Client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<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.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory, Oracle.ManagedDataAccess.EntityFramework"></defaultConnectionFactory>
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
-Nuget installed: Oracle.DataAccess.x86 - v.2.112.1
-Nuget 安装:Oracle.DataAccess.x86 - v.2.112.1
Oracle.ManagedDataAccess.EntityFramework - v.12.2.20190115
Oracle.ManagedDataAccess.EntityFramework - v.12.2.20190115
Oracle.ManagedDataAccess - v.12.2.1100
Oracle.ManagedDataAccess - v.12.2.1100
EntityFramework - v.6.2.0
实体框架 - v.6.2.0
installed ODAC : ODTwithODAC122011.zip
已安装 ODAC:ODTwithODAC122011.zip

