繁体   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