Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider replacing hardcoded student IDs in the Seed the Database section with live values #34350

Open
PragmaticIT opened this issue Dec 12, 2024 · 1 comment

Comments

@PragmaticIT
Copy link

PragmaticIT commented Dec 12, 2024

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

@tdykstra
Copy link
Contributor

Thanks for the suggestion. We'll implement it the next time we update the tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants