Skip to main content

Working with Entity Framework Core inside JetBrains Rider

· 4 min read
Andrii Rublov

image

Read about UI way of working with Entity Framework Core inside JetBrains Rider

Introduction

With the release of Entity Framework Core, developers finally have the opportunity to work with migrations, databases and DbContext without being tied to Powershell or Visual Studio.

Now, you can make any change related to EF Core via dotnet ef (after installing the corresponding .NET CLI Tool), for example:

dotnet ef migrations add Initial

This approach allows you to customize any command to the smallest detail by adding all necessary settings for expected result.

However, for more complex commands, you need to remember their syntax and the names of the required parameters. In addition, using the IDE, I would like to be able to execute the same commands using the user interface, as for example, when working with git.

Now this feature has appeared in JetBrains Rider, via the plugin Entity Framework Core UI!

How to install

There are 2 ways of how plugin could be installed:

Using marketplace:

note

For EAP users: you should add https://plugins.jetbrains.com/plugins/eap/list to your repositories list before installing

  1. Go to Settings / Plugins / Marketplace
  2. Search for "Entity Framework Core UI"
  3. Click Install, then Save
  4. After saving restart Rider

Using .zip file

  1. Go to Releases
  2. Download latest release of plugin for you version (current stable ot EAP)
  3. Proceed to Settings / Plugins / / Install plugin from disk
  4. Select downloaded .zip file with plugin, click Ok
  5. Click Save
  6. After saving restart Rider

Features

Before you start, you must have dotnet ef installed as a global .NET CLI tool. If it is not already installed, the plugin will suggest you to install it in 1 click when opening a solution that contains an EF Core-supported project:

All plugin features could be accessed through Project context menu -> Tools -> Entity Framework Core:

If you have different projects for Startup and Migrations, you could use any of them. After first submitted command the project pair will be saved for future use for better experience of running next commands.

Adding migrations

note

This dialog (and dialogs for all other features) contains all commonly customizable options, including build options during dotnet ef execution, project pair and DbContext dropdowns.

Only supported projects are listed here, so you will not be confused by all unrelated projects in the list.

In case when migration with the same "Migration name" exist, you will not be able to complete this dialog.

It guards againts mistyping.

After clicking OK, dotnet ef command will be executed with given options, the same way, as you execute it by hand.

Database updating

When updating database, you need to provide target migration. It has nice auto-complete feature to help you in specifing proper migration.

It also autoselects last created migrations for given Migrations project.

You are able to provide "0" value there to undo all applied migrations. Migration existance is validated for this input field too!

Removing last migration

This dialog provides no specific options, you could just hit Ok and last created migration will be removed.

Note that your migration project should have at least 1 migration created.

Database dropping

Same as for "Remove Last Migration", but before sumbitting you will be notified that this action can't be undone:

Roadmap

In future releases, it is also planned to add Database scaffolding functionality for DB-first development. In addition, there are several suggestions for improving plugins and adding more high-level functionality, such as Squash migrations.

Full roadmap you could find here.

You can also suggest your own feature! This can be done through Discussions here.

Limitations

Currently plugin supports only projects targeting net5.0 and net6.0 frameworks. You also need to have proper version of EF Core Tools installed to support specific projects.

The best option is to have .NET 6 SDK with EF Core Tools 6.0 installed.

Contribution

The plugin is distributed as an Open-source project. You can also contribute to its development by helping to implement open issues, create bug reports, and any other changes through Pull requests.