簡體   English   中英

EF System.MissingMethodException

[英]EF System.MissingMethodException

我在 c# 項目中從數據庫 SqlCe 生成 EF model 時遇到問題。 這是一個新錯誤,因為多年來我已經更新了很多次。 我嘗試了很多方法來解決它,也在研究 web,但沒有任何幫助我解決。 我還將 NET Framework 更改為 4.6.2。

C# 項目使用 NETFramework 4.5 和 EF 6.2、EF.SqlCe 6.2。

這是錯誤消息:

Generating the model took 00:00:30.5059377.
Unable to generate the model because of the following exception: 'System.MissingMethodException: Method not found: 'Boolean System.Data.Entity.Core.Common.DbProviderManifest.SupportsParameterOptimizationInSchemaQueries()'.
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.CreateFilteredCommand(String sql, String orderByClause, EntityStoreSchemaFilterObjectTypes queryTypes, List`1 filters, String[] filterAliases)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadDataTable[T](String sql, Func`2 orderByFunc, DataTable table, EntityStoreSchemaFilterObjectTypes queryTypes, IEnumerable`1 filters, String[] filterAliases)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadTableDetails(IEnumerable`1 filters)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadStoreSchemaDetails(IList`1 filters)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GetStoreSchemaDetails(StoreSchemaConnectionFactory connectionFactory)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.CreateStoreModel()
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String storeModelNamespace, ModelBuilderSettings settings, List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils, ModelBuilderEngineHostContext hostContext)'.
Loading metadata from the database took 00:00:01.5131055.
Generating the model took 00:00:04.8109160.

任何想法?

非常感謝

運行(以管理員身份)這個命令對我有用:

gacutil /u EntityFramework

然后需要重新啟動 Visual Studio。 舊版本的程序集可能已安裝到 GAC。

我重新安裝了 VS 2017,現在可以使用了!!

我在使用 VS 2017 時遇到過這個問題。以下是我為擺脫這個問題而采取的步驟。

  1. 轉到“C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\EntityFramework”文件夾位置
  2. 從上述文件夾中剪切“EntityFramework.dll”並保存在某處
  3. 轉到EF項目並更新模型,沒有任何錯誤

希望這會有所幫助。 謝謝。

就我而言,我有 2 個包引用相同 dll 的不同版本。 例如,用於 mysql 和 sqlite 的 EntityFramework 包指的是不同版本的 EntityFramework 核心庫

當這樣看時,明顯的解決辦法是

  • 刪除其中一個沖突的包或
  • 確保您為兩個軟件包提供 select 版本,該版本引用沖突 dll 的相同或兼容版本。 Nuget package 管理器在這方面很有用。

請記住,有時,您的 IDE 可能需要重新啟動才能捕獲任何更改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM