我在Visual Studio 2013中安装了
Windows 8.1 64位.我安装了最新的Oracle ODAC 12c第3版32位测试版,声称支持EF 6.当我将ADO.NET实体框架添加到我的项目并选择我的Oracle时数据连接,它不允许我选择Entity Framework 6.0版本.它选择了Entity Framework 5.x,版本6.x显示为灰色.它表示“无法为您的数据连接找到与最新版本的实体框架兼容的实体框架数据库提供程序”.这是为什么?
解决方法
我做了以下工作以使其工作: –
首先安装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
并修改您的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,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,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>