Scaffolding not working in neither .net 7 and 6

Matías Bustos 20 Reputation points
2023-10-24T18:07:33.4933333+00:00

Hello, I am following the following tutorial to create the model with its respective crud, using the scaffolding generator from the following link:

https://learn.microsoft.com/es-mx/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-7.0&tabs=visual-studio

The issue is that the generator does not work in any of the versions tried in the title and throws the following error:
User's image

the error in english can be:

Error

Error running the selected code generator: "Error restoring package. Reverting package changes for "WebApplication5"

This happens when I follow the model creation from the tutorial and also create the folder inside Pages > Movies and generate the scaffold with the Entity Framework CRUD template in the movies folder.

I tried cleaning the nugget packages but with no results, also i dont have nugget packages installed so is very strange.

I dont know if this extra details could be helpfull:

arch: x64
Edición Windows 10 Home Single Language

Version 22H2

Compilation of OS 19045.3570

Experience Windows Feature Experience Pack 1000.19052.1000.0

Regards

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,311 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,793 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,535 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,286 Reputation points
    2023-10-24T23:43:32.1666667+00:00

    I recommend using EF Power Tools to reverse engineer your database than creating pages for EF Core the DbContext and models will be picked up in the tooling.

    Also make sure to have the following in your project file.

    <ItemGroup>
       <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
    	   <PrivateAssets>all</PrivateAssets>
    	   <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       </PackageReference>
    
       <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
       <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
    	   <PrivateAssets>all</PrivateAssets>
    	   <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       </PackageReference>
    
       <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.10" />
    </ItemGroup>
    			
    

    And your connection setup in Program.cs


0 additional answers

Sort by: Most helpful