Error when scaffolding in ASP.NET Core MVC

Jędrzej Koriat 0 Reputation points
2024-07-25T06:55:49.2+00:00

Hello!

I have an error whenever I try to scaffold a new scaffold element:User's image

It says:

"Error

An error occurred while running the selected code generator:

"Exception of type 'System.InvalidOperationException' was thrown."

This is a link to my project: https://github.com/jedrulcia/TrainingPlanApp.Web.git

Thanks in advance!

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,400 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SurferOnWww 2,491 Reputation points
    2024-07-25T08:08:55.32+00:00

    Please check if the versions of the NuGet packages required for the scaffolding match:

    • Microsoft.EntityFrameworkCore.SqlServer
    • Microsoft.EntityFrameworkCore.Tools
    • Microsoft.VisualStudio.Web.CodeGeneration.Design

  2. Jędrzej Koriat 0 Reputation points
    2024-07-25T16:42:38.3466667+00:00

    Okay so I have observed that I had some issues since I added NUnit Test project to my solution. This was one of these issues that I had:
    User's image

    Whenever I opened the solution I had to comment these lines. However, I could work on my project anyways, so I wasn't bothered by it. But now I thought this could also affect scaffolding, and that was actually the issue. I have deleted the NUnit folder and project from my solution and it is working now. I do not need to have to unit tests for my project for now anyways, but leaving the comment if that would help anyone in future.

    0 comments No comments