microsoft/aspire · error · InvalidOperationException

Conflicting values for 'CommandTimeout' were found in

Error message

Conflicting values for 'CommandTimeout' were found in {nameof(OracleEntityFrameworkCoreSettings)} and set in DbContextOptions<{typeof(TContext).Name}>.

What it means

Guard in EnrichOracleDatabaseDbContext: the application set CommandTimeout in OracleEntityFrameworkCoreSettings while the DbContext's own options (DbContextOptionsBuilder in OnConfiguring/AddDbContext) also specify a CommandTimeout. Aspire refuses to pick a winner because the two sources conflict and silently overriding one would surprise the other configuration path.

Solutions

  1. Set CommandTimeout in only one location (settings or DbContext options)
  2. Align both values so they are equal
  3. Omit CommandTimeout from the settings to let the DbContext option stand

Example fix

// before
builder.EnrichOracleDatabaseDbContext<MyDbContext>(s => s.CommandTimeout = 120);
// DbContext: UseOracle(..., o => o.CommandTimeout(30))
// after
builder.EnrichOracleDatabaseDbContext<MyDbContext>(s => s.CommandTimeout = 30); // match, or remove one
Defensive patterns

Strategy: validation

Validate before calling

var settingsTimeout = aspireSettings.CommandTimeout;
var optionsTimeout = dbContextOptions.Extensions.OfType<OracleOptionsExtension>().FirstOrDefault()?.CommandTimeout;
if (settingsTimeout.HasValue && optionsTimeout.HasValue && settingsTimeout != optionsTimeout)
    throw new InvalidOperationException("CommandTimeout differs between Aspire settings and DbContext options.");

Try / catch

try
{
    builder.EnrichOracleDatabaseDbContext<MyDbContext>();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Conflicting values for 'CommandTimeout'"))
{
    logger.LogError(ex, "CommandTimeout is set in two places with different values.");
    throw;
}

Prevention

When it happens

Trigger: Calling EnrichOracleDatabaseDbContext with settings.CommandTimeout set while the DbContext's OracleOptionsExtension has a different CommandTimeout (e.g. configured in UseOracle options delegate or OnConfiguring).

Common situations: Timeout set in DbContext configuration and later also in Aspire settings; values diverged after changing one place only; environment-specific overrides introducing a mismatch.

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.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/78bcca33309f6891. Report an issue: GitHub.

Appendix: source

Thrown at src/Components/Aspire.Oracle.EntityFrameworkCore/AspireOracleEFCoreExtensions.cs:167

                                }
                                else
                                {
                                    options.ExecutionStrategy(context => new OracleRetryingExecutionStrategy(context));
                                }
                            }
                            else
                            {
                                options.ExecutionStrategy(context => new OracleRetryingExecutionStrategy(context));
                            }
                        }

                        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(OracleEntityFrameworkCoreSettings)} 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, OracleEntityFrameworkCoreSettings settings) where TContext : DbContext
    {
        if (!settings.DisableTracing)
        {
            builder.Services.AddOpenTelemetry().WithTracing(tracerProviderBuilder =>
            {
                tracerProviderBuilder.AddOracleDataProviderInstrumentation(settings.InstrumentationOptions);

View on GitHub (pinned to 25830f84bd)