1

Creating my first web app. Using ASP.NET and Razor Pages+. Developing it in VS 2017.

(Note: Similar to unanswered S.O. question ASP.NET Core : Generate Razor Pages for all models)

+In ASP.NET Core tutorials [https://learn.microsoft.com/en-us/aspnet/core/tutorials/?view=aspnetcore-2.1] it says this: "Razor Pages is the recommended approach to create a new Web UI app with ASP.NET Core 2.0."

First thing I did was create my database using SSMS:

enter image description here

Then, I created a ASP.NET Core Web Application

enter image description here

Then, I created a model from the existing database (Used only the Reverse engineer your model step of Getting Started with EF Core on ASP.NET Core with an Existing Database

enter image description here

Then, I used the Scaffold the movie model step of Add a model to a Razor Pages app in ASP.NET Core

enter image description here

The scaffolding step requires that you choose one class from the Models folder and produces generically-named CRUD pages in (my case) the Pages\keyw_status folder.

If I scaffold the 2nd and 3rd classes from my model, the generically-named CRUD pages in the Pages\keyw_status folder will be overwritten. Last model class scaffolded wins, right?

How do I scaffold a 3-table model using Razor Pages?

VA systems engineer
  • 2,856
  • 2
  • 14
  • 38

1 Answers1

1

You can specify the folder for the scaffolded pages using the -outDir option to ensure that the CRUD pages for each entity are generated in different folder. Usually, people pick the name of the entity for the folder, because that becomes your URL.

The following command will scaffold CRUD pages for the DateTable entity, and place them in Pages\DataTable.

dotnet aspnet-codegenerator razorpage -m DateTable -dc keyw_statusContext -udl -outDir Pages\DateTable
Mike Brind
  • 28,238
  • 6
  • 56
  • 88