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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/oracle/206314.html

猜你在找的Oracle相关文章