Skip to content

Migrations Tool

Erik Ejlskov Jensen edited this page Dec 11, 2020 · 9 revisions

This tool is currently in Preview state, so bumps may occur!

The tool helps you manage EF Core Migrations in your project using a graphical user interface (GUI), and without requiring you to install any tools packages in your project.

For general information about EF Core Migrations, see the documentation

To start using the Migrations Tool, create your POCO classes and DbContext, and install the required EF Core provider, as described for example here until the step: Create your database.

There is no need to install the Microsoft.EntityFrameworkCore.Tools package as described, you can use the graphical Migrations Tool instead!

Create your database

Now that you have a model, you can use the Migrations Tool to create a database for you.

  • Right click your project -> EF Core Power Tools -> Migrations Tool

The tool will check the status of migrations in your project, and detect that you have made model changes without a related migration.

pt

Enter a name for the migration and choose "Add Migration". The tool will create the migration, and discover that the migration has not been applied to your database. Choose "Update Database" to apply the migration to the database. Because your database doesn't exist yet, it will be created for you before the migration is applied.

pt

Now you database and model are in sync!

pt

You can use the "Script Migrations" button to create a idempotent SQL script, that scripts all migrations in your project.

If you make future changes to your model, you can run the tool again to scaffold a new migration to make the corresponding schema changes to the database. Once you have checked the scaffolded code (and made any required changes), you can use the tool to apply the changes to the database.