Table of Contents

# EF Core CLI Migration Usage

Use EF Core

Define a simple class added to DBConext.

Add migration

To add a migration, use the following command:

dotnet ef migrations add InitialCreate

This command creates a new migration file with the name InitialCreate in the Migrations folder.

Tip

Remember to check the migration code, which would have been generated in the Migrations folder. Ensure that the migration file contains the necessary changes to the database schema.

Remove migraion

Remove the last migration.

dotnet ef migrations remove

Apply migraion to database

dotnet ef database update

If you want an update to a specific migration.

dotnet ef database update <migration_name>

Reference