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

Razor Pages Tutorial - Seed Data as Migration #7342

Closed
jabberhams opened this issue Jun 28, 2018 · 4 comments
Closed

Razor Pages Tutorial - Seed Data as Migration #7342

jabberhams opened this issue Jun 28, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@jabberhams
Copy link

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!

@guardrex
Copy link
Collaborator

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.

@guardrex
Copy link
Collaborator

Cross-ref: #7699

@guardrex
Copy link
Collaborator

Be on the lookout for "seeding" remarks in the repo. Example: #7727

@Rick-Anderson
Copy link
Contributor

@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.

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

No branches or pull requests

4 participants