Cannot locate Microsoft.VisualStudio.Web.CodeGeneration.Design

Barry Pocock 0 Reputation points
2024-03-06T04:33:35.68+00:00

Just installed "ASP.net and web development" - and started with the tutorial "RazorPagesMovie" - step 2. On adding "New Scaffolded Item" I get "Error - There was an error running the selected code generator: 'Package restore failed. Rolling Back package changes for "RazorPagesMovie" Beating on the internet I found

  1. https://stackoverflow.com/questions/65285501/error-when-trying-to-add-a-scaffolded-item-in-razor-pages
  2. https://github.com/dotnet/Scaffolding/issues/1540
  3. https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/intro?view=aspnetcore-5.0&tabs=visual-studio

Basically I believe have to install a variety of packages

Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9"
Include="Microsoft.VisualStudio.Web.CodeGeneration.Core" Version="3.1.

going into Project / Manages NuGet Packages - I do not see them - where do I find these packages and how do I install them (if they are already installed - it creates an even bigger problem)

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

2 answers

Sort by: Most helpful
  1. AgaveJoe 28,036 Reputation points
    2024-03-06T11:07:16.9033333+00:00

    The error means there is a mismatch of library versions. The libraries you posted are very old and no longer supported. You should move to a supported version of .NET like .NET 8.

    https://dotnet.microsoft.com/en-us/download/dotnet/8.0


  2. SurferOnWww 2,661 Reputation points
    2024-03-08T01:14:17.38+00:00

    Basically I believe have to install a variety of packages

    No, you do not have to install any NuGet packages manually. If you did it, probably the issue is caused by the mismatch of NuGet versions as AgaveJoe mentioned in his answer.

    I understand that you followed the following Microsoft tutorial. Please note that the tutorial does not instruct to add any NuGet packages.

    Tutorial: Create a Razor Pages web app with ASP.NET Core

    If you exactly follow the instruction in the tutorial, the required NuGet packages will be automatically installed in the project at the step of "Scaffold the movie model" in the Part 2.

    enter image description here

    I suggest you uninstall all the NuGet packages and then try "Scaffold the movie model" in the Part 2 again.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.