EF Core 11 adds a repository-level way to set defaults for dotnet ef: put them in .config/dotnet-ef.json. The tool searches upward from your current working directory for the first matching file, and any option you provide explicitly on the command line takes precedence. This feature is documented for EF Core 11; do not expect it in earlier versions. Microsoft’s EF Core tools reference documents the behavior.
Where to put the configuration file
Create a file named dotnet-ef.json inside a .config directory. For repository-wide defaults, that usually means <repository-root>/.config/dotnet-ef.json. The CLI searches upward from the current working directory and uses the first matching file it finds. As a result, commands run from a repository subdirectory can use the root configuration, provided no nearer matching file is found. Microsoft documents this discovery rule.
As an Amazon Associate I earn from qualifying purchases.
Which defaults can you set?
All properties are optional. Add only the values that are stable and useful for your repository:
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →| Property | Value type | What it sets |
|---|---|---|
project |
String | Target project for the command. |
startupProject |
String | Startup project used when the tools build and run the application at design time. |
framework |
String | Target framework. |
configuration |
String | Build configuration. |
context |
String | DbContext to use. |
runtime |
String | Target runtime. |
verbose |
Boolean | Whether to enable verbose output. |
noColor |
Boolean | Whether to disable colored output. |
prefixOutput |
Boolean | Whether to prefix output. |
Microsoft lists these properties and their types in the .NET CLI tools reference.
#1 Best Overall
Example: set defaults for a multi-project solution
This illustrative configuration follows Microsoft’s reference. Replace the project paths, framework, context, and runtime with values that fit your solution:
{
"project": "src/App.Infrastructure",
"startupProject": "src/App.Api",
"framework": "net11.0",
"configuration": "Debug",
"context": "AppDbContext",
"runtime": "win-x64",
"verbose": true,
"noColor": false,
"prefixOutput": false
}
In this example, project and startupProject are different on purpose. The target project receives the command’s changes; the startup project is built and run at design time. A multi-project solution may need both roles to be explicit. The EF Core tools documentation distinguishes them.
Rank #2
How relative project paths are resolved
Relative values for project and startupProject are resolved from the parent directory of the .config directory containing the file—not from whichever subdirectory you happen to run the command in. For a root-level .config/dotnet-ef.json, a value such as src/App.Infrastructure is relative to the repository root. Microsoft specifies this path base.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Override a default for one command
Keep repository-wide values in the JSON file, then pass an option explicitly when a particular invocation needs a different value. Explicit command-line options take precedence over configuration-file values. Microsoft states in its EF Core tools reference: “Explicit command-line options always take precedence over values from the configuration file.” This makes the file a shared default rather than a restriction on individual commands. See the official precedence rule.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When this feature is available
Configuration-file support for dotnet ef is introduced in EF Core 11, according to Microsoft’s CLI reference. If you use an earlier EF Core version, this file-based defaults feature is not documented as available there; continue supplying the needed options directly or upgrade to a version that supports it. Check Microsoft’s version-scoped reference.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




