How to Seed Data to EF Core
Introduction We all know EF Core Migrations . They have been around for quite some time, some people like them, others prefer alternatives (hello, Flyway , DbUp , FluentMigrator !). I'm not going to discuss that, but, instead, how to seed data to a database, either using EF Core migrations or not. This is, of course, for inserting initial/reference data that must always be present, for Microsoft's opinion on this, please see this page . This post assumes that you know about migrations - how to create and apply them, at least, and that you have all it takes for it, including EF Core Tools and the Microsoft.EntityFrameworkCore.Design NuGet package. For actually adding data, we have essentially four options: Explicit insertions Data-only migrations Entity configuration Context configuration (explicit seeding) Let's see them all one by one. Using Explicit Insertions The first case is pretty obvious: we add data explicitly after we forced pending migrations ...