O'Reilly logo

ASP.NET Core: Cloud-ready, Enterprise Web Application Development by James Singleton, Valerio De Sanctis, Mugilan T. S. Ragupathi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required