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 #8138

Closed
Rick-Anderson opened this issue Aug 17, 2018 — with docs.microsoft.com · 3 comments
Closed

Razor Pages Tutorial - Seed Data as Migration #8138

Rick-Anderson opened this issue Aug 17, 2018 — with docs.microsoft.com · 3 comments
Milestone

Comments

Copy link
Contributor

Rick-Anderson commented Aug 17, 2018

Migrated from #7342 - complete #8137 before this issue.
@jabberhams wrote:

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!


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@Rick-Anderson
Copy link
Contributor Author

@guardrex wrote:

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.

@Rick-Anderson
Copy link
Contributor Author

Won't change

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