微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我正在尝试使用适用于Oracle数据库的实体框架6构建一个MVC 5 Web应用程序,我试图使用ODAC 12c第3版,其中包括对实体框架6代码优先和代码优先迁移的支持; 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实体数据模型,代码优先的模型。

我在我的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,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,PublicKeyToken=89b483f429c47342" />
    </providers>
  </entityFramework>

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

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

您的项目引用最新版本的实体框架;但是,与您的连接无法找到与此版本兼容的实体框架数据库提供者…

如何正确配置我的应用程序能够使用ODAC与EF6代码

我终于能够用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

通过在Package Manager Console中运行以下命令,可以使用NuGet安装EF6.1.1(您可以通过Tools-> NuGet Package Manager – > Package Manager Console输入):

Install-Package EntityFramework -Version 6.1.1

修改您的web.config或web.config以使用Oracle.ManagedDataAccess,通过添加提供程序和有效的连接字符串,例如:

<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="Oracle.ManagedDataAccess.Client" type="OracleInternal.Common.ODPMSectionHandler,Version=4.121.2.0,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,EntityFramework" />
    <providers>
      <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices,Version=6.121.2.0,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实体模型添加模型来检查它是否正常工作

原文地址:https://www.jb51.cc/oracle/206314.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐