Please consider replacing hardcoded student IDs in the Seed the Database section with live values #34350
Labels
aspnet-core/svc
data-access/subsvc
Source - Docs.ms
Docs Customer feedback via GitHub Issue
⌚ Not Triaged
Description
Hi
In the Seed the database section (here) new Enrollment entities are created using hardcoded (assumed) StudentID like in the following line:
new Enrollment{StudentID=1,CourseID=1050,Grade=Grade.A},
instead, the live ID can be used by just refering to the student entity by refering to its index in the array defined before:
new Enrollment{StudentID=students[1].ID,CourseID=1050,Grade=Grade.A}
This method makes the solution more futureproof and opens it to a new experiments like using GUIDs instead of autogenerated IDs etc.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/intro?view=aspnetcore-9.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/data/ef-rp/intro.md
Document ID
fa488196-1f98-08ea-adcc-17d9dac86727
Article author
@tdykstra
Related Issues
The text was updated successfully, but these errors were encountered: