c# - EF System.MissingMethodException

标签 c# entity-framework

我在 c# 项目中从 Database SqlCe 生成 EF 模型时遇到问题。 这是一个新错误,因为多年来我已经更新了很多次。 我尝试了很多方法来解决它,也在网上研究,但没有什么能帮助我解决。我还将 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。

关于c# - EF System.MissingMethodException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50561934/

相关文章:

wpf - Catel + EntityFramework

c# - 在 ASP.net MVC 5 服务器或客户端中缓存的位置

c# - ASP.NET Core 在 Linux 上的 Visual Studio Code 中调试时修改 View

entity-framework - TFS 2010中单个文件的自动排他 checkout

entity-framework - 如何编辑以前应用的迁移而不先在 EF 代码中添加另一个迁移

c# - DDD 将 Entity Framework 数据模型映射到领域模型

c# - 从调用异步的 BackgroundWorker 中抛出异常。方法(网络请求)

c# - 在 NHibernate 对象上使用动态代理

c# - 将动态创建的 SQL 参数作为匿名类型传递到 dapper

c# - 将多个 Include() 与嵌套 Select() 结合使用时出现 EntityCommandExecutionException