October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Stop Repeating dotnet ef Flags with Repository Defaults in EF Core 11

EF Core 11 can load dotnet ef defaults from .config/dotnet-ef.json, with upward file discovery and command-line options taking precedence.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.Support on Ko-Fi

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.