-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Razor Pages Tutorial - Seed Data as Migration #7342
Comments
Hello @jabberhams Thanks for commenting. They finished their work for data seeding with the 2.1 release. AFAIK based on our prior discussions on this subject, we'll be moving to this approach:
WRT sample updates, I'm performing the 2.1 update pass without seeding changes. I'll circle back. We can use this issue to track the work. |
Cross-ref: #7699 |
Be on the lookout for "seeding" remarks in the repo. Example: #7727 |
@jabberhams thanks for opening this issue. Moving this issue to #8138 so it shows up in the docs. We'd welcome you making the change but unfortunately for a tutorial series it's not straightforward to update code as we use code snippets/snap shots for different stages. When were ready to update the docs we'll invite you to contribute if that's OK. I think we'll want to using seed-migrations in #8137 first. |
Summary
Update the SQL Server LocalDB seed data step of the ASP.NET Core Razor Pages tutorial to perform a database migration of the seed data rather than initializing during startup.
Overview
The SQL database step in the Razor Pages tutorial here (md file here) includes instructions for adding seed data to grow the size of the sample set, which enables functionality in later steps (i.e. search and adding new fields). Readers are instructed to create an initializer class and then call it from
Startup.cs
after retrieving the db context. The initializer will skip its work if it finds any existing records in the database table, which is ensured by previous steps in the tutorial. To get around this, there are also one-off steps to delete all records in the database and restart IIS.As a matter of best practices, adding seed data to a database could be considered a database migration. A more effective approach would be to create an EF migration step and run the migration.
This approach removes the one-off steps and, more importantly, gives readers a better model for constructing these types of database updates for their own apps.
I have the seed data migration step code, so I don't mind taking on the task of re-writing this page to reflect the code changes.
Thank you!
The text was updated successfully, but these errors were encountered: