There was an error running the selected code generator: Could not load file or assembly Microsoft.EntityFrameworkCore, version = 2.0.1.0

强颜欢笑 提交于 2019-12-23 09:15:49

问题


When I was creating a Controller and a View by MVC Controller with views, using Entity Framework I got an error.

The Error is:

There was an error running the selected code generator: 'Could not load file or assembly Microsoft.EntityFrameworkCore, version = 2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' the located assembly's manifest definition does not match the assembly reference

Creating MVC Controller with views, using Entity Framework:

How can I solve this problem?

I use Visual Studio Version 15.5.2 and version of Microsoft.AspNetCore.All is 2.0.0


回答1:


I updated the Microsoft.AspNetCore.All to version 2.0.3 and now it does work right.




回答2:


Go to NugetPackage Manager and update the Microsoft.AspNetCore.All package




回答3:


I had a similar issue but mine was something with the versioning of visual studio.

I went to Visual Studio Installer and it notified me that I had to restart my computer




回答4:


Update your packages or it can happen when you have an older SDK. Download a new .NET Core SDK and runtime from www.microsoft.com/net




回答5:


I got this same error:

Running Preview 2019 and .NET Core 3.

I moved the Nuget pkg sources up in my list.

I was attemping to add a new Controller and I would get this error every time.

I also noticed that for some reason I chose not to set up SSL but I had the setting in my launchSettings.json.

I deleted the setting for ssl and built the app and ran it. After the successful run I could add the Controller without the error.




回答6:


For me none of the above solutions worked. I had to add Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.Design packages even though I have Microsoft.AspNetCore.All package added to my project.

Edit project in VS 2007 and add these lines

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" /> 
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.3" />



回答7:


Having the same error, after downloaded VS2019"PREVIEW" and then opened a core 3.0 project there I was able to scaffold content no errors at all..



来源:https://stackoverflow.com/questions/48081118/there-was-an-error-running-the-selected-code-generator-could-not-load-file-or-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!