Search⌘ K

Data Seeding and Custom Migrations

Explore how to use Entity Framework Core's data seeding to populate initial data and create custom migrations with raw SQL commands. Understand how to manage migration files, update databases, and ensure reliable Up and Down methods for schema integrity.

Data seeding

Data seeding involves populating the database with initial data. It is useful for the following:

  • Providing test data in a development environment.
  • Setting up initial data in a development/production environment.

Note: The commands in this lesson generate code and files. Through the terminal, we can navigate to these files by using relevant Linux commands such as ls to view a list of files and directories, cd to change directories, and cat to view file contents. A SPA widget showing the updated project with the generated files is also available. Also, note that EF Core uses a timestamp within the generated file names. We represent these names with xxx.

In an earlier lesson, we mentioned that the Tags table holds a set of categories for the artists’ albums. In this section, we use migrations to ...