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://docs.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
:
Then, I created a ASP.NET Core Web Application
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
Then, I used the Scaffold the movie model
step of Add a model to a Razor Pages app in ASP.NET Core
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
?
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