JetBrains Rider
 
Get JetBrains Rider
Get your hands on the new features ahead of the release by joining the Early Access Program for Rider 2025.1! Learn more

Entity Framework Core: Scaffold DbContext

Last modified: 04 December 2024

This command generates code for a DbContext and entity types from the selected database. To generate each entity type using this command, the corresponding database table must have a primary key.

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

Below is the list of options for the Scaffold DbContext command.

Common

Connection

Select the source database. You can choose from databases added to the Database window Ctrl0\,0S.

Provider

The provider to use. Typically, this is the name of the NuGet package, for example, Microsoft.EntityFrameworkCore.SqlServer.

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.

Additional Options

Output folder

The folder where the migration classes will be generated.

Use attributes to generate the model

Where possible, use attributes to configure the model. Otherwise, only the fluent API is used.

Use database names

Use table, view, sequence, and column names exactly as they appear in the database. Otherwise, database names can be changed according to the C# name style conventions.

Generate OnConfiguring method

By default, the command creates the OnConfiguring method in the generated DbContext class. Clear this checkbox to disable that.

Use the pluralizer

Automatically pluralize entity class names and DbSet properties in the generated DbContext to match the expected singular or plural forms.

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  CtrlAlt0S.

Additional arguments

Any additional arguments to pass to the application.