简体   繁体   中英

How Do I Configure my Web App to Work with Oracle 12c Release 3 (12.1.0.1.0)?

Thanks for looking

I have written an app that uses Entity Framework 6 which is supposedly supported by Oracle Data Provider 12c R3.

I have installed this version of the ODP, but I am having trouble making it work. I have tried following the configuration instructions , yet I still get this error when my code tries to access any Oracle entities:

0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.DataAccess.Client'.

NOTE: I am aware that there are many other StackOverflow questions on this subject, but most of them are older and do not take into consideration the newer version of ODP which DOES support EF 6.

Any help is appreciated.

I finally was able to to use ODP with EF6.

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

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.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):

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 :

 <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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM