2014-10-30 49 views
1

感謝您尋找如何配置我的Web應用程序以使用Oracle 12c第3版(12.1.0.1.0)?

我寫了使用實體框架6是由Oracle數據提供商12C R3據說支持的應用程序。

我已經安裝了這個版本的ODP,但是我很難使它工作。我曾嘗試以下的configuration instructions,但是當我的代碼試圖訪問任何Oracle實體我仍然得到這個錯誤:

0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.DataAccess.Client'.

注:我知道有關於這個問題的許多其他StackOverflow的問題,但其中大部分是較舊的,並沒有考慮到支持EF 6的ODP的新版本。

任何幫助表示讚賞。

回答

1

我終於可以在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實體模型添加模型來檢查它是否工作

相關問題