3

我試圖用Oracle創建一個實體數據模型。我收到這個錯誤。您的項目引用了實體框架的最新版本... - 錯誤

enter image description here

我安裝這兩個我的解決方案。

enter image description here

我,也爲2015年VS

安裝ODT這是我引用顯示。

enter image description here

的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.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> 
</configSections> 
<connectionStrings> 
    <add name="OracleDbContext" 
     providerName="Oracle.ManagedDataAccess.Client" 
     connectionString="User Id=system;Password=myPassword;Data Source=ABC_DB" /> 
</connectionStrings> 
<appSettings> 
    <add key="webpages:Version" value="3.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
</appSettings> 
<system.web> 
    <authentication mode="None" /> 
    <compilation debug="true" targetFramework="4.5.2" /> 
    <httpRuntime targetFramework="4.5.2" /> 
</system.web> 
<system.webServer> 
    <modules> 
     <remove name="FormsAuthentication" /> 
    </modules> 
</system.webServer> 
<runtime> 
........ 
</runtime> 
<entityFramework> 
    <defaultConnectionFactory 
     type="Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory, Oracle.ManagedDataAccess.EntityFramework"> 
    </defaultConnectionFactory> 
    <providers> 
     <!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
     <provider invariantName="Oracle.ManagedDataAccess.Client" 
        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />--> 
     <provider invariantName="Oracle.ManagedDataAccess.Client" 
        type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> 
    </providers> 
</entityFramework> 
<system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
    </compilers> 
</system.codedom> 
<system.data> 
    <DbProviderFactories> 
     <remove invariant="Oracle.ManagedDataAccess.Client" /> 
     <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> 
    </DbProviderFactories> 
</system.data> 
<oracle.manageddataaccess.client> 
    <version number="*"> 
    <dataSources> 
    <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " /> 
    </dataSources> 
</version> 
</oracle.manageddataaccess.client> 

我缺少什麼?

回答

1

,你必須去你proyect - >屬性 - >編譯 - >,並設置平臺,86

保存所有更改,重建,添加實體數據模型,現在它會奏效。

它發生在我們的工作很多次!

這是因爲ODT是32位的,可能你的項目是AnyCpu或x64,操作系統是x64。

希望它可以幫助

+0

我不知道..現在我卡住了一個不同的錯誤,「聽者不currenlty知道.......... 「。我不記得我做了什麼改變。我所要做的就是使用DB第一種方法獲取運行Oracle數據庫的MVC應用程序。我正在使用VS 2015,它也有Oracle的官方支持。但無法運行這個東西。它很愚蠢。我想我應該轉移到SQL Server。甲骨文真是令人沮喪,如此混亂。 – adityawho

+0

起初有點棘手,但一旦你配置了它的屬性,它就可以正常工作。與監聽器相關,你應該檢查你的tnsnames.ora文件 – ssanga

0

安裝實體框架,如果它沒有安裝,改造項目,並添加一個新的連接。它爲我解決了這個問題。

0

我設法通過將實體框架更新爲6.1.3,將Oracle託管數據訪問更新爲12.1.24160719並將Oracle託管數據訪問實體框架更新爲12.1.2400來解決此問題。請使用nuget管理器進行更新。在此之後,它工作!

3

「您的項目引用最新版本的實體框架」問題與VS 2017和Oracle 12c 當我們添加項目ADO.NET實體數據模型與Oracle連接,然後錯誤消息顯示「您的項目引用最新版本的實體框架...「

解決步驟在這裏;

  1. 從AnyCPU

  2. 更改活動解決方案平臺,32位在VS2017安裝Oracle ODTwithODAC122010爲32位

  3. 創建項目

  4. 打開工具 - >的NuGet PackageManager->爲解決方案管理Nuget包

5 - 寫瀏覽區 「ODP」 並安裝下面的程序

  • 甲骨文。ManagedDataAccess

  • Oracle.ManagedDataAccess.EntityFramework

6-打開工具 - >的NuGet PackageManager->包管理器控制檯

7-寫這

- Install-Package EntityFramework -Version 6.1.1 

and Enter 

8級的重啓動Visual Studio完成該過程

8-Re-Build您的應用程序

8添加新項ADO.NET實體數據模型

9 - 如果需要添加新連接到Oracle(數據源= Oracle數據庫(ODP.NET,管理驅動程序))

10 - 一切都好。

注意:我的EF6.1.3不適用於VS2017和Oracle ODTwithODAC122010。但經過所有這些過程,我已將EF作爲EF6.1.3更改爲 但我不建議您。

1

我今天遇到這個問題。然後我通過以下步驟解決:

通常情況下,如果我們想在實體框架中使用MySQL,我們將添加一些DLL,如MySql.Data,MySql.Data.Entity.EF6。

但是我們忘了Visual Studio需要使用MySQL的一件事。

那就是把上的App.config/Web.config中配置:

<configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 

<entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider></providers> 
    </entityFramework> 
<system.data> 
    <DbProviderFactories> 
     <remove invariant="MySql.Data.MySqlClient" /> 
     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> 
    </DbProviderFactories> 
    </system.data> 

然後,建立你的整個項目,然後再試一次。

另一種解決方案是:使用Nuget添加MySQL dll。它將被添加到App.config/Web.config文件