Implementing a data seed strategy

We have created the database, yet it's still completely empty. In order to test it against our existing application, it could be useful to find an easy way to add some sample data programmatically.

In the most recent EF versions, up to and including EF6, it was possible to do that using the DbMigrationsConfiguration.Seed() method. Unfortunately though, a migrations configuration doesn't exist in EF Core: this seems to be more an implementation choice than a lack of features since the seeding tasks can now be handled directly within the Startup.cs file.

Note

Although this is definitely true, there is still a controversy going on between the EF Core developers community regarding that specific aspect. The absence of ...

Get ASP.NET Core: Cloud-ready, Enterprise Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.