Update read-related-data.md (#7608)
parent
995a84e6e7
commit
ffccdf3adb
|
@ -69,20 +69,12 @@ To display the name of the assigned department in a list of courses:
|
|||
* 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.
|
||||
|
||||
Build the project. The build generates errors like the following:
|
||||
|
||||
`1>Pages/Courses/Index.cshtml.cs(26,37,26,43): error CS1061: 'SchoolContext' does not
|
||||
contain a definition for 'Course' and no extension method 'Course' accepting a first
|
||||
argument of type 'SchoolContext' could be found (are you missing a using directive or
|
||||
an assembly reference?)`
|
||||
|
||||
Globally change `_context.Course` to `_context.Courses` (that is, add an "s" to `Course`). 7 occurrences are found and updated.
|
||||
|
||||
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.
|
||||
|
||||
Run the app and select the **Courses** link. The department column displays the `DepartmentID`, which isn't useful.
|
||||
|
|
Loading…
Reference in New Issue