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.
We'll cover the following...
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
lsto view a list of files and directories,cdto change directories, andcatto 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 withxxx.
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 ...