加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 14:02:41 所属栏目:百科 来源:网络整理
导读:我正在尝试使用适用于Oracle数据库的实体框架6构建一个MVC 5 Web应用程序,我试图使用ODAC 12c第3版,其中包括对实体框架6代码优先和代码优先迁移的支持; NuGet,.NET Framework 4.5.2;和ODP.NET,托管驱动程序XML DB。按照 http://www.oracle.com/technetwo
我正在尝试使用适用于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实体模型添加模型来检查它是否正常工作

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读