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

Use EF Core 2.1 Seed feature in "Create an MVC web app" tutorial #9282

Closed
wants to merge 6 commits into from
Closed

Use EF Core 2.1 Seed feature in "Create an MVC web app" tutorial #9282

wants to merge 6 commits into from

Conversation

dannevesdantas
Copy link
Contributor

Closes #9205

Updated the Create an MVC web app tutorial to use EF Core 2.1 Seed feature in MvcMovieContext instead of a separate SeedData class. The goal is to reduce the amount of code necessary to seed data and consequently decrease the complexity to beginners, also making the docs more didactic by introducing the EF core 2.1 seed feature.

  • Updated the v2.1 sample project code to seed data in MvcMovieContext through EF core 2.1
  • Added a migration named SeedData in the v2.1 sample project to be able to insert the seed data in the database.
  • Updated the Rating existing migration in the v2.1 sample project to deal with seed data in MvcMovieContext.
  • Updated the Seed the database tutorial’s section to seed data in MvcMovieContext class instead of SeedData class (only in the 2.1 docs version).
  • Updated the Add a new field tutorial’s section to add the Rating field to the MvcMovieContext class instead of the SeedData class (only in the 2.1 docs version).
  • The asp.net core <= 2.0 version of the tutorial continues using the SeedData class as it is. No changes in the asp.net core <= 2.0 sample project or tutorial instructions.
  • Split the Seed the database tutorial’s section into two different files (seed-db.md and seed-db-21.md) to improve docs maintenance and markdown code readability.

Feedbacks are welcome!
Thanks so much!

…ng method

Seeding data by overriding the OnModelCreating method of the MvcMovieContext class.
With application data being sown at MvcMovieContext, calling the SeedData.Initialize() in Program.cs is not required anymore.
With the inclusion of seed data in MvcMovieContext a new Migration named “SeedData” was generated to insert seed data in the db. The old “Rating” Migration was removed and a new “Rating” Migration was generated to properly deal with the MvcMovieContext changes.
…n MvcMovieContext

Updating the "Seed the database" section to use EF 2.1 Seed feature on MvcMovieContext instead. Asp.net core <= 2.0 version of the tutorial continues using the SeedData class as it is.
…MvcMovieContext

Updating the "Add a new field" section to use EF 2.1 Seed feature on MvcMovieContext instead. Asp.net core <= 2.0 version of the tutorial continues using the SeedData class as it is.
Deleting the SeedData class in the v2.1 sample project as it’s not required anymore. No other references to these files were found in the docs.
@dnfclas
Copy link

dnfclas commented Oct 29, 2018

CLA assistant check
All CLA requirements met.

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

Successfully merging this pull request may close these issues.

2 participants