Entity Framework Core 2.1: Tools – Getting Help

Whether you use Visual Studio’s Package Manager Console, or the dotnet CLI, it is likely that in the past you have already used commands from the Entity Framework Core tool. A command that we have used a lot is to add migrations, Add-Migration, and also the command to update the database, Update-Database. Although these two commands are important, they are not the only ones. In this and the next entries we will learn to use the EF Core commands.

In this post we will see how to get help from any command of Entity Framework Core.

In Visual Studio, we typically use the Package Manager Console to execute Entity Framework commands. The Package Manager Console is located at: Tools > Nuget Package Manager > Package Manager Console. Also, if you do not have it, you must install this Nuget package to use the Entity Framework Core command-line interface in your project:

Install-Package Microsoft.EntityFrameworkCore.Tools

Help commands: Get-Help and -h

The most important command is the one that gives you help with the other commands. When you have doubts about a command, you will typically have two options:

  1. Continue reading this blog 🙂
  2. Use the Get-Help command to get help

Since you are already executing option 1, it is worth talking about option 2. For example, suppose we do not know what options the Add-Migration command brings, which is used to add migrations, that is, to describe in classes changes that will be made in our database. We can get information about that command by using the following code in Visual Studio’s Package Manager Console:

get-help Add-Migration

Or, if you use the dotnet CLI:

dotnet ef migrations add -h

In both cases, a set of information will be presented, these contain a brief description of the command, as well as the possible parameters that we can use. If this information is not enough, you can ask for detailed information. In the Package Manager Console you can request detailed information as follows:

get-help Add-Migration -detailed

In the case of dotnet CLI, by default the help is already “detailed”.

In the Package Manager Console, we have several levels of help, such as:

detailed: where we are presented with general information about the command and its arguments.
full: we are presented with all the available information of the command, including characteristics of its arguments, such as what are required.

Personally, I tend to use the -detailed option more because the information given in the -full option I find it somewhat overwhelming and unnecessary.

In the following entries we will see all the commands offered by the Entity Framework Core command tool.

To see the list of all commands, run this command in the Package Manager Console:

Get-Help EntityFrameworkCore

And you’ll get a list like the following:

The following Entity Framework Core commands are available.

Add-Migration: Adds a new migration.
Drop-Database: Drops the database.
Get-DbContext: Gets information about a DbContext type.
Remove-Migration: Removes the last migration.
Scaffold-DbContext: Scaffolds a DbContext and entity types for a database.
Script-Migration: Generates a SQL script from migrations.
Update-Database: Updates the database to a specified migration.


Use the Get-Help command in the Package Manager Console to obtain information about how to use another command. Example:

Get-Help Add-Migration

In the case of dotnet CLI, you must use the -h option after the command:

dotnet ef migrations add -h

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s