diff --git a/aspnetcore/data/ef-rp/concurrency.md b/aspnetcore/data/ef-rp/concurrency.md index 4f074d8050..a76b122b2e 100644 --- a/aspnetcore/data/ef-rp/concurrency.md +++ b/aspnetcore/data/ef-rp/concurrency.md @@ -147,24 +147,23 @@ The preceding commands: ## Scaffold the Departments model -* Exit Visual Studio. -* Open a command window in the project directory (The directory that contains the *Program.cs*, *Startup.cs*, and *.csproj* files). -* Run the following command: +# [Visual Studio](#tab/visual-studio) + +Follow the instructions in [Scaffold the student model](xref:data/ef-rp/intro#scaffold-the-student-model) and use `Department` for the model class. + +# [.NET Core CLI](#tab/netcore-cli) + + Run the following command: ```console dotnet aspnet-codegenerator razorpage -m Department -dc SchoolContext -udl -outDir Pages\Departments --referenceScriptLibraries ``` +------ + The preceding command scaffolds the `Department` model. Open the project in Visual Studio. -Build the project. The build generates errors like the following: - -`1>Pages/Departments/Index.cshtml.cs(26,37,26,43): error CS1061: 'SchoolContext' does not - contain a definition for 'Department' and no extension method 'Department' accepting a first - argument of type 'SchoolContext' could be found (are you missing a using directive or - an assembly reference?)` - - Globally change `_context.Department` to `_context.Departments` (that is, add an "s" to `Department`). 7 occurrences are found and updated. +Build the project. ### Update the Departments Index page diff --git a/aspnetcore/data/ef-rp/read-related-data.md b/aspnetcore/data/ef-rp/read-related-data.md index 25dc66dfa2..2c876ea21a 100644 --- a/aspnetcore/data/ef-rp/read-related-data.md +++ b/aspnetcore/data/ef-rp/read-related-data.md @@ -64,15 +64,20 @@ To display the name of the assigned department in a list of courses: ### Scaffold the Course model -* Exit Visual Studio. -* Open a command window in the project directory (The directory that contains the *Program.cs*, *Startup.cs*, and *.csproj* files). -* Run the following command: +# [Visual Studio](#tab/visual-studio) + +Follow the instructions in [Scaffold the student model](xref:data/ef-rp/intro#scaffold-the-student-model) and use `Course` for the model class. + +# [.NET Core CLI](#tab/netcore-cli) + + Run the following command: ```console - dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 2.1.0 dotnet aspnet-codegenerator razorpage -m Course -dc SchoolContext -udl -outDir Pages\Courses --referenceScriptLibraries ``` +------ + The preceding command scaffolds the `Course` model. Open the project in Visual Studio. Open *Pages/Courses/Index.cshtml.cs* and examine the `OnGetAsync` method. The scaffolding engine specified eager loading for the `Department` navigation property. The `Include` method specifies eager loading. @@ -145,20 +150,21 @@ In the *SchoolViewModels* folder, create *InstructorIndexData.cs* with the follo ### Scaffold the Instructor model -* Exit Visual Studio. -* Open a command window in the project directory (The directory that contains the *Program.cs*, *Startup.cs*, and *.csproj* files). -* Run the following command: +# [Visual Studio](#tab/visual-studio) + +Follow the instructions in [Scaffold the student model](xref:data/ef-rp/intro#scaffold-the-student-model) and use `Instructor` for the model class. + +# [.NET Core CLI](#tab/netcore-cli) + + Run the following command: ```console dotnet aspnet-codegenerator razorpage -m Instructor -dc SchoolContext -udl -outDir Pages\Instructors --referenceScriptLibraries ``` -The preceding command scaffolds the `Instructor` model. Open the project in Visual Studio. - -Build the project. The build generates errors. - -Globally change `_context.Instructor` to `_context.Instructors` (that is, add an "s" to `Instructor`). 7 occurrences are found and updated. +------ +The preceding command scaffolds the `Instructor` model. Run the app and navigate to the instructors page. Replace *Pages/Instructors/Index.cshtml.cs* with the following code: