Skip to content

ASP.NET Core scaffolding tool #7672

@mostmate

Description

@mostmate

Description

error generated by running code in visual studio CLI:
PM> dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Data.SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries -sqlite
dotnet : Scaffolding failed.
At line:1 char:1

  • dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Data.Scho ...
  •   + CategoryInfo          : NotSpecified: (Scaffolding failed.:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    

Could not find project file in C:\Users\awise303\source\repos\ContosoUniversity

############################################################
Alternatively tried manual installation and still get error even after rebuilding project. The following error:

dotnet : Could not find any project in C:\Users\awise303\source\repos\ContosoUniversity\.
At line:1 char:1

  • dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
  •   + CategoryInfo          : NotSpecified: (Could not find ...soUniversity\`.:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    
    

by following theses steps:

Create a Pages/Students folder.
In Solution Explorer, right-click the Pages/Students folder and select Add > New Scaffolded Item.
In the Add New Scaffold Item dialog:
In the left tab, select Installed > Common > Razor Pages
Select Razor Pages using Entity Framework (CRUD) > ADD.
In the Add Razor Pages using Entity Framework (CRUD) dialog:
In the Model class drop-down, select Student (ContosoUniversity.Models).
In the Data context class row, select the + (plus) sign.
Change the data context name to end in SchoolContext rather than ContosoUniversityContext. The updated context name: ContosoUniversity.Data.SchoolContext
Select Add to finish adding the data context class.
Select Add to finish the Add Razor Pages dialog.
The following packages are automatically installed:

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

Configuration

Regression?

Other information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions