Oracle ODP.Net With Entity Framework 6 - Entity framework database compatible provider could not be found
Asked Answered
S

8

38

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

http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html

I have VS 2013 Community Edition update 4 .

Am trying to add Model using ADO.Net Entity Data Model , With Code First.

I have the following configured in my 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.

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:

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 ?

Steamtight answered 26/12, 2014 at 11:30 Comment(1)
I had the same issue, then found this (oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/…), where they say: Select Build > Rebuild Solution from the Visual Studio menu, which will allow this project to start using Entity Framework 6. That fixed my problem...Belle
S
42

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

Steamtight answered 26/12, 2014 at 11:30 Comment(8)
In my application I have everything set, but I'm still getting the same error.Bromo
This might be noteworthy. I had referenced the above mentioned references in my data layer library project, but not in the web application project and got this error. For whatever reason, adding the Oracle.ManagedDataAccess.EntityFramework reference to my application project fixes it.Id
well, I had the same problem when I tried to do it manually, but all these problems were resolved via ODP.NET Nuget package: nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework. The only concern that remains is change the project build to x86.Coldiron
@Wasef Before following the above steps, i was getting error message mentioned in OP's question i.e. 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... but now after following the steps when I choose the Oracle database in Choose Your Data Connection' dialog and press Next, i dont see the Choose Your Version` dialog (the dialog on which I was getting the error message` rather it straight away goes to the next step of Choose your Database Objects and SettingsTrebuchet
@Wasef Does this mean My db is going to use Entity Framework 6.x version? or still there is something wrong? is there any way to confirm which EF version is being used in my app?Trebuchet
@ps_prakash02 , You can do that , follow my steps to configure EF, and add a new item to your project and from there Add New ADO.Net Data Model.Steamtight
@WasimQadir If you followed my steps Yes it will use EF6Steamtight
Just a note - you can just Install-Package Oracle.ManagedDataAccess.EntityFramework to get this via Nuget now.Enrage
Q
18

Just to complement, i've tried everything but in my case it was solved by setting the "defaultConnectionFactory", like this:

<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

I hope it helps someone...

Quadrat answered 26/1, 2016 at 16:25 Comment(4)
Actually this is the only solution if you don't want to spoil your machine with ODAC. Well done Sir!Burden
Thanks! This solved it for me after trying everything else.Xeniaxeno
Thanks! I have ODAC due to version compatibility issues, so not using managed driver. For me this also worked: Oracle.DataAccess.EntityFramework.OracleConnectionFactoryInterleaf
Yes, changing defaultConnectionFactory to Oracle type did work for me! Thanks!!Forrester
N
2

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.

I'm using VS2017 15.7.4, Oracle 12g, and EF 6.1.1.

I decided to downgrade Oracle.ManagedDataAccess.EntityFramework and Oracle.ManagedDataAccess from 18.3.0 to 12.2.1100 and it finally worked!

Narwhal answered 31/8, 2018 at 21:12 Comment(1)
which version of Oracle.ManagedDataAccess.EntityFramework and Oracle.ManagedDataAccess did you use to solve this ?Shonna
C
1

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.

Capful answered 27/2, 2017 at 13:13 Comment(0)
P
1

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.

All dev-workstations had oracle-odac-drivers ver4.122.1.0 & ver6.122.1.0 installed system-wide (GAC etc).

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.

We didn't have time to look any further into all this but the aforementioned solution worked for VS2017.

Pneumatograph answered 20/11, 2017 at 10:52 Comment(0)
B
1

For me, installing this Nuget packages works. https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/

Breazeale answered 3/5, 2018 at 8:32 Comment(1)
which version did you install ?Shonna
D
1

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.

Datolite answered 26/9, 2018 at 9:7 Comment(0)
G
0

My Computer : Win 7 64 bit

VS 2015

Oracle Server :

version 12G - 32 bit

What I have tried until success :

-downgrade Oracle.ManagedDataAccess.EntityFramework and Oracle.ManagedDataAccess from 18.3.0 to 12.2.20190115

-Change Build mode from Any CPU to x86

-Configuration 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

Oracle.ManagedDataAccess.EntityFramework - v.12.2.20190115

Oracle.ManagedDataAccess - v.12.2.1100

EntityFramework - v.6.2.0

installed ODAC : ODTwithODAC122011.zip

Guayule answered 23/4, 2019 at 3:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.