Oracle ODP.Net与实体框架6 - 无法找到实体框架数据库兼容的提供程序

Was*_*awi 37 .net oracle entity-framework ado.net-entity-data-model odac

我正在尝试使用适用于Oracle数据库的Entity Framework 6构建MVC 5 Web应用程序,我正在尝试使用ODAC 12c第3版,其中包括对Entity Framework 6 Code First和Code First Migrations的支持; NuGet,.NET Framework 4.5.2; 和ODP.NET,托管驱动程序XML DB.按照

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

我有VS 2013社区版更新4.

我试图使用ADO.Net实体数据模型添加模型,使用Code First.

我在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>
Run Code Online (Sandbox Code Playgroud)

我还添加了Oracle.ManagedDataAccess版本4.121.2.0作为参考并重建解决方案.

我现在尝试使用ADO.Net实体数据模型添加模型,使用Code First.但是在向导的最后一个屏幕中收到以下消息:

您的项目引用了最新版本的实体框架; 但是,找不到与此版本兼容的Entity Framework数据库提供程序...

如何正确配置我的应用程序以便能够首先使用带有EF6代码的ODAC?

Was*_*awi 40

我终于能够在EF6上使用ODP了.

我做了以下工作以使其工作: -

首先安装ODAC 12c第3版,其中包括对实体框架6代码优先和代码优先迁移的支持; NuGet,.NET Framework 4.5.2; 和ODP.NET,托管驱动程序XML DB.按照

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

将两个引用添加到我的项目引用中,它们是:

Oracle.ManagedDataAccess.dll

Oracle.ManagedDataAccess.EntityFramework.dll

通过在软件包管理器控制台中运行以下命令,使用NuGet安装EF6.1.1(可以通过Tools-> NuGet软件包管理器 - >软件包管理器控制台输入):

Install-Package EntityFramework -Version 6.1.1
Run Code Online (Sandbox Code Playgroud)

并修改您的web.config或web.config以使用Oracle.ManagedDataAccess,方法是添加Provider和有效的连接字符串,例如:

<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>
Run Code Online (Sandbox Code Playgroud)

将您的应用程序重建为x86,并开始使用EF6,您可以使用代码优先使用ADO.Net实体模型添加模型来检查它是否有效

  • 在我的应用程序中,我已经设置了所有内容,但我仍然遇到同样的错误. (3认同)
  • 好,我有同样的问题,当我试图做手工,但所有这些问题都通过ODP.NET NuGet包解决:https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/.剩下的唯一问题是将项目构建更改为x86. (2认同)
  • 只需注意 - 您现在只需`安装 - 打包Oracle.ManagedDataAccess.EntityFramework`即可通过Nuget获取此信息. (2认同)

Fer*_*mes 18

为了补充,我尝试了一切,但在我的情况下,通过设置" 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>
Run Code Online (Sandbox Code Playgroud)

在这里找到了解决方案:https://community.oracle.com/message/13114643#13114643

我希望它可以帮助某人......