JetBrains Rider 2024.3 Help

Entity Framework Core: Update Database

This command updates a database using the specified migration. To update production databases, you can also use an SQL script that you can create with the Generate SQL Script command.

Under the hood, JetBrains Rider will apply the dotnet ef database update command with the corresponding arguments. Make sure that dotnet ef global tool is installed on your machine.

  1. Do one of the following:

    • Right-click the desired project in the Solution Explorer and choose Entity Framework Core | Update Database.

    • Select Tools | Entity Framework Core | Update Database from the main menu.

  2. A dialog will appear where you can specify all necessary options.

    JetBrains Rider: Entity Framework Core: Update Database
  3. In the dialog, specify options for updating the database. By default, JetBrains Rider saves the options from previous invocations of EF Core commands and automatically fills most of the fields . If you want to disable this, clear the Autofill general options (for fields with non-sensitive information) and Autofill additional options (for connection strings and related options) checkboxes on the Tools | EF Core UI settings page  Ctrl+Alt+S.

  4. Click OK to apply the command. JetBrains Rider will execute the ef core database update command with the corresponding arguments.

    By default, the command output will be displayed in a new tab of the EF Core tool window. If you prefer to see the command progress in the status bar and the results of the command in a popup, clear the Execute commands in terminal checkbox on the Tools | EF Core UI settings page  Ctrl+Alt+S.

Below is the list of options for the Update Database command.

Common

Target migration

Specifies the migration that will be applied to the database. 0 allows you to reset to the state of the database before the first migration.

Migrations project

The project where the command will be applied. If you have invoked the command from the context menu of a specific project, this project will be preselected.

Startup project

Project to be run when you start your application, containing the entry point or startup logic (like the Main method or Startup.cs in ASP.NET Core). It provides the necessary runtime configuration, dependency injection setup, and configuration context, such as connection strings and service registrations.

DbContext class

DbContext migration class to use for the command. You can choose from available migrations classes in the selected Migrations project.

Additional Options

Use the default connection of the startup project

By default, JetBrains Rider will use the default database connection specified in the startup project. If you want to use a different connection, clear this checkbox and enter the desired connection. This can be either a connection string or a connection name from the project settings (in the format Name=ConnectionStrings:SomeName).

If you want to reuse the custom connection for future database updates, select the Autofill additional options checkbox on the Tools | EF Core UI settings page  Ctrl+Alt+S.

Be careful when using this option. When connection strings are automatically filled, a wrong connection string might be accidentally used for non-local database modifications.

Build Options

Skip project build process

Use this option when the build is up to date. Although this option reduces the execution time of the command, it may also be a source of potential problems if the project has not been built before running the command.

Build configuration

Build configuration of the startup project, for example, Debug or Release.

Target framework

Target runtime to restore packages for when building the startup project.

Execution

Enable diagnostic logging

Show verbose output if the Execute commands in terminal checkbox is enabled on the Tools | EF Core UI settings page  Ctrl+Alt+S.

Additional arguments

Any additional arguments to pass to the application.

Last modified: 03 December 2024