Introduction to Migrations

Learn how to create migrations and update a database with them.

Overview

In real-world projects, data models get updated as features get implemented. New entities or properties get added and removed. Migrations provide a means to update the database schema and keep it in sync with the model. This approach is known as the Code First workflow because the EF Core model is the source of truth.

Migrations are generated from data models and update the database schema

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.

Creating and applying migrations

A migration is a point-in-time snapshot of the data model. EF Core generates migration source files based on the ...

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy