I'm trying to scaffold controller for Entity Framework Core using ASP.NET Core Web API 3.1.
My database works fine, I can add new migrations and update the actual database.
The problem is that, once I install the packages and try to scaffold a new controller, the package version from 5.0.3
goes down to 3.1.12
for EntityFramework.Tools
and EntityFramework.SqlServer
.
What happens is that, I install the required versions of EntityFrameworkCore
, EntityFrameworkCore.Design
, EntityFramework.Tools
and EntityFramework.SqlServer
, in my case I install them as 5.0.3
version. Once installed, I'm trying to scaffold a new controller with entity framework like this:
- Click right mouse on the Controllers folder and click
Add
- Select
New Scaffold Item
- Select
API Controller with actions, using EntityFramework
Unfortunately, I'm not able to create a controlled. I'm getting the error below:
There was an error running the selected Code Generator: 'Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.VisualStudio.Web.CodeGeneration.ConsoleLogger' from assembly Microsoft.VisualStudio.Web.CodeGeneration.Core, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.Main(String [] args)
What I've tried:
- Clearing Nuget cache
- Uninstalling and installing all the packages all over again
- Updating visual studio version
- Adding additional attributes to my csproj file for the actual packages.
- Creating a new empty project, installing the packages and scaffolding a controller. It still does not work??
- Reinstalling visual studio
This stack question did not help me:
ASP.NET Core 1.1.1 MVC with EF Core - not able to scaffold from controller class
I don't understand. I update my packages versions to 5.0.3
but once I try to scaffold a new controller, the package versions are being downgrade to 3.1.12
automatically.
How is this possible? Any additional ideas, how I could fix this issue?