如何配置Web应用程序以与Oracle 12c版本3(12.1.0.1.0)配合使用?
谢谢你的关注 我已经编写了一个应用程序,它使用Entity Framework 6,据推测Oracle数据提供商12c R3支持该应用程序 我已经安装了这个版本的ODP,但是我在使它工作时遇到了困难。我尝试了以下操作,但当我的代码尝试访问任何Oracle实体时仍会出现此错误:如何配置Web应用程序以与Oracle 12c版本3(12.1.0.1.0)配合使用?,oracle,entity-framework,ado.net,odp.net,Oracle,Entity Framework,Ado.net,Odp.net,谢谢你的关注 我已经编写了一个应用程序,它使用Entity Framework 6,据推测Oracle数据提供商12c R3支持该应用程序 我已经安装了这个版本的ODP,但是我在使它工作时遇到了困难。我尝试了以下操作,但当我的代码尝试访问任何Oracle实体时仍会出现此错误: 0152:未找到具有固定名称“Oracle.DataAccess.Client”的ADO.NET提供程序的实体框架提供程序。 注意:我知道在这个主题上还有很多其他StackOverflow问题,但大多数问题都比较老,没有考
0152:未找到具有固定名称“Oracle.DataAccess.Client”的ADO.NET提供程序的实体框架提供程序。
注意:我知道在这个主题上还有很多其他StackOverflow问题,但大多数问题都比较老,没有考虑到支持EF 6的新版ODP
非常感谢您的帮助。我终于能够将ODP与EF6一起使用了 我做了以下工作使其工作: 首先安装ODAC 12c版本3,其中包括对Entity Framework 6代码优先和代码优先迁移的支持;NuGet、.NETFramework 4.5.2;以及ODP.NET,托管驱动程序XML数据库。依照 向我的项目引用添加两个引用,它们是: Oracle.ManagedDataAccess.dll Oracle.ManagedDataAccess.EntityFramework.dll 通过在Package Manager控制台中运行以下命令,使用NuGet安装EF6.1.1(您可以通过工具->NuGet Package Manager->Package Manager控制台进行输入): 并通过添加提供程序和有效的连接字符串,修改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>
将应用程序重建为x86,并开始使用EF6,您可以先使用代码添加一个使用ADO.Net实体模型的模型来检查它是否工作
<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>