Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion entity-framework/core/cli/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: EF Core tools reference (.NET CLI) - EF Core
description: Reference guide for the Entity Framework Core .NET CLI tools
author: SamMonoRT
ms.date: 11/08/2024
ms.date: 04/22/2026
uid: core/cli/dotnet
---

Expand Down Expand Up @@ -386,6 +386,60 @@ The following example creates a script for all migrations after the InitialCreat
dotnet ef migrations script 20180904195021_InitialCreate
```

## Configuration file

> [!NOTE]
> This feature was introduced in EF Core 11.

Starting with EF Core 11, `dotnet ef` can load default option values from a JSON configuration file. This reduces the need to repeat the same command-line options across multiple invocations.

### File location and discovery

Place a file named `dotnet-ef.json` inside a `.config` directory:

```text
<repository root>/
└── .config/
└── dotnet-ef.json
```

When `dotnet ef` runs, it walks up the directory tree from the current working directory and uses the first `.config/dotnet-ef.json` file it finds. This means you can place the file at the root of your repository and it will be used from any subdirectory.

### Supported properties

The configuration file is a JSON object with the following optional properties:

```json
{
"project": "src/App.Infrastructure",
"startupProject": "src/App.Api",
"framework": "net11.0",
"configuration": "Debug",
"context": "AppDbContext",
"runtime": "win-x64",
"verbose": true,
"noColor": false,
"prefixOutput": false
}
```

| Property | Type | Description |
|:-----------------|:--------|:--------------------------------------------------------------------------------------------------------------------------------------------|
| `project` | string | Relative or absolute path to the target project folder. Relative paths are resolved relative to the parent of the `.config` directory containing the file. |
| `startupProject` | string | Relative or absolute path to the startup project folder. Relative paths are resolved relative to the parent of the `.config` directory containing the file. |
| `framework` | string | The [Target Framework Moniker](/dotnet/standard/frameworks#supported-target-framework-versions) for the target framework. |
| `configuration` | string | The build configuration, for example: `Debug` or `Release`. |
| `context` | string | The `DbContext` class to use. Class name only or fully qualified with namespaces. |
| `runtime` | string | The identifier of the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the [RID catalog](/dotnet/core/rid-catalog). |
| `verbose` | boolean | Enable verbose output. |
| `noColor` | boolean | Disable colored console output. |
| `prefixOutput` | boolean | Prefix output lines with their severity level. |

All properties are optional. Only include the properties you need.

> [!NOTE]
> Explicit command-line options always take precedence over values from the configuration file.

## Additional resources

* [Migrations](xref:core/managing-schemas/migrations/index)
Expand Down
28 changes: 27 additions & 1 deletion entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: What's New in EF Core 11
description: Overview of new features in EF Core 11
author: roji
ms.date: 02/02/2026
ms.date: 04/22/2026
uid: core/what-is-new/ef-core-11.0/whatsnew
---

Expand Down Expand Up @@ -631,6 +631,32 @@ Remove-Migration -Offline
Drop-Database -Connection "Server=test;Database=MyDb;..." -Force
```

<a name="dotnet-ef-config-file"></a>

### Configuration file for dotnet ef
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for me - technically this isn't only a migrations feature, right? (because other cmdline tool usage are also affected by it)? Though we expect it will mostly help out with migration management?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, be we don't have a section for CLI features


The `dotnet ef` command-line tool now supports loading default option values from a `.config/dotnet-ef.json` configuration file. This eliminates the need to repeatedly specify the same options — such as `--project` and `--startup-project` — across every command invocation.

When you run `dotnet ef`, the tool searches for a `.config/dotnet-ef.json` file by walking up the directory tree from the current working directory. The first file found is used. Here's an example configuration file:

```json
{
"project": "src/App.Infrastructure",
"startupProject": "src/App.Api",
"framework": "net11.0",
"configuration": "Debug",
"context": "AppDbContext",
"runtime": "win-x64",
"verbose": true,
"noColor": false,
"prefixOutput": false
}
```

Explicit command-line options always take precedence over configuration file values. Path values for `project` and `startupProject` are resolved relative to the parent of the `.config` directory containing the file.

For more information, see [Configuration file](xref:core/cli/dotnet#configuration-file).

## Other improvements

* The EF command-line tool now writes all logging and status messages to standard error, reserving standard output only for the command's actual expected output. For example, when generating a migration SQL script with `dotnet ef migrations script`, only the SQL is written to standard output.
Loading