我終於可以在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
安裝EF6。 1.1通過在軟件包管理器控制檯中運行以下命令來使用NuGet(您可以通過工具 - > NuGet軟件包管理器 - >軟件包管理器控制檯輸入):
Install-Package EntityFramework -Version 6.1.1
和修改您的web.config或web.config中使用Oracle.ManagedDataAccess,通過增加供應和有效的連接字符串如:
<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>
重新構建應用程序爲X86,並開始使用EF6,您可以使用Code First使用ADO.Net實體模型添加模型來檢查它是否工作