Oracle ODP.Net With Entity Framework 6 - Entity fr

2019-01-31 06:30发布

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 ?

7条回答
放荡不羁爱自由
2楼-- · 2019-01-31 07:27

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.

查看更多
登录 后发表回答