x19
x19

Reputation: 8783

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

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

Upvotes: 15

Views: 20912

Answers (8)

Abhay Shekhar Yadav
Abhay Shekhar Yadav

Reputation: 121

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

Upvotes: 0

Crennotech
Crennotech

Reputation: 519

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" />

Upvotes: 4

Gabor Nagy
Gabor Nagy

Reputation: 19

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

Upvotes: -1

raddevus
raddevus

Reputation: 9077

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.

Upvotes: 0

juFo
juFo

Reputation: 18567

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

Upvotes: 1

Neil Busse
Neil Busse

Reputation: 149

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

Upvotes: 0

Sajithd
Sajithd

Reputation: 557

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

Upvotes: 6

x19
x19

Reputation: 8783

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

Upvotes: 10

Related Questions