12
votes

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 The error image

Creating MVC Controller with views, using Entity Framework: 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

8

8 Answers

9
votes

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

7
votes

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

3
votes

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 2017 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" />
1
votes

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

0
votes

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

0
votes

I got this same error:

error running selected code generator

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.

0
votes

enter image description here

Follow these Steps:-

From Tools

  • Select NuGet Package Manager -> Manage NuGet Packages For Solution click on ->Updates Select the checkbox Select All ->Select Your Project from right hand side -> Click on Upadate
-1
votes

VS2019PreviewHaving 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..