EF System.MissingMethodException

时间:2018-05-28 08:17:50

标签: 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.

有什么想法吗?

非常感谢

3 个答案:

答案 0 :(得分:2)

运行(以管理员身份)此命令对我有用:

gacutil /u EntityFramework

然后需要重新启动Visual Studio。旧版本的程序集可能已安装到GAC。

答案 1 :(得分:0)

我重新安装了VS 2017,现在可以使用!!

答案 2 :(得分:0)

我在使用 VS 2017 时遇到过这个问题。以下是我为摆脱这个问题而采取的步骤。

  1. 转到“C:\Windows\Microsoft.NET\assembly\GAC_MSIL\EntityFramework” 文件夹位置
  2. 从上面的文件夹中剪切“EntityFramework.dll” 并保存在某处
  3. 转到 EF 项目并更新模型,没有任何错误

希望这会有所帮助。谢谢。