microsoft/aspire · error · InvalidOperationException
Conflicting values for 'CommandTimeout' were found in
Error message
Conflicting values for 'CommandTimeout' were found in {nameof(PomeloEntityFrameworkCoreMySqlSettings)} and set in DbContextOptions<{typeof(TContext).Name}>. What it means
The Aspire MySQL EF enrichment sets CommandTimeout from PomeloEntityFrameworkCoreMySqlSettings. If the DbContextOptions already carry a CommandTimeout that differs from the settings value, Aspire throws rather than picking one silently, because two sources of truth would be ambiguous.
Solutions
- Make the values identical: set the same CommandTimeout in both PomeloEntityFrameworkCoreMySqlSettings and the DbContextOptions.
- Remove the CommandTimeout from settings (leave it null) so the value already on DbContextOptions is used.
- Remove the explicit CommandTimeout from the DbContextOptions configuration and let Aspire apply the settings value.
Example fix
// before builder.AddMySqlDbContext<MyDbContext>(connectionName); // appsettings: PomeloEntityFrameworkCoreMySql:CommandTimeout = 30 // DbContextOptions already: options.CommandTimeout = 60 // after builder.AddEnrichMySqlDbContext<MyDbContext>(connectionName, settings => settings.CommandTimeout = 60); // match existing value
Defensive patterns
Strategy: validation
Validate before calling
var configuredTimeout = new DbContextOptionsBuilder<TContext>().Options.CommandTimeout;
if (settings.CommandTimeout is int t && configuredTimeout is int ct && t != ct)
throw new InvalidOperationException($"CommandTimeout mismatch: settings={t}, options={ct}"); Try / catch
try { builder.EnrichMySqlDbContext<TContext>(name); }
catch (InvalidOperationException ex) when (ex.Message.Contains("CommandTimeout"))
{ /* unify the value in one place and retry/enrich */ } Prevention
- Define CommandTimeout in exactly one source of truth (prefer Aspire settings).
- Never set CommandTimeout both in AddDbContext options and component settings.
- Keep timeout values in environment-specific configuration validated by a startup check.
When it happens
Trigger: Calling AddEnrichMySqlDbContext with settings.CommandTimeout set (e.g. 30) while DbContextOptions<MyContext> already had CommandTimeout configured to a different value (e.g. via UseMySql(..., mySqlOptions => mySqlOptions.CommandTimeout = 60) or ConfigureDbContext).
Common situations: CommandTimeout set previously in AddDbContext, then Aspire settings added in appsettings.json with a different value; copy-pasted settings between environments; timeout tuned in one place after introducing Aspire.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- . needs to be set when a custom Execution Strategy is…
- Conflicting values for 'CommandTimeout' were found in
- Conflicting values for 'CommandTimeout' were found in
- A DbContextOptions< > was not found. Please ensure…
- ASPIRERADIUS011
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/42ed214d78479ce9.
Report an issue: GitHub.
Appendix: source
Thrown at src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/AspireEFMySqlExtensions.cs:228
}
else
{
options.EnableRetryOnFailure();
}
}
else
{
options.EnableRetryOnFailure();
}
}
if (settings.CommandTimeout.HasValue)
{
if (extension != null &&
extension.CommandTimeout.HasValue &&
extension.CommandTimeout != settings.CommandTimeout)
{
throw new InvalidOperationException($"Conflicting values for 'CommandTimeout' were found in {nameof(PomeloEntityFrameworkCoreMySqlSettings)} and set in DbContextOptions<{typeof(TContext).Name}>.");
}
options.CommandTimeout(settings.CommandTimeout);
}
});
}
}
#pragma warning restore EF1001 // Internal EF Core API usage.
}
}
private static void ConfigureInstrumentation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] TContext>(IHostApplicationBuilder builder, PomeloEntityFrameworkCoreMySqlSettings settings) where TContext : DbContext
{
if (!settings.DisableHealthChecks)
{
// calling MapHealthChecks is the responsibility of the app, not Component
builder.TryAddHealthCheck(View on GitHub (pinned to 25830f84bd)