microsoft/aspire · error · InvalidOperationException

. needs to be set when a custom Execution Strategy is…

Error message

{nameof(OracleEntityFrameworkCoreSettings)}.{nameof(OracleEntityFrameworkCoreSettings.DisableRetry)} needs to be set when a custom Execution Strategy is configured.

What it means

EnrichOracleDatabaseDbContext detects an ExecutionStrategy whose exact type is not OracleExecutionStrategy (any subclass is custom) and throws because automatic retry cannot be combined with a custom strategy — DisableRetry must be explicitly set to acknowledge this.

Solutions

  1. Set DisableRetry = true via the settings callback: builder.EnrichOracleDatabaseDbContext<TContext>(s => s.DisableRetry = true)
  2. Remove the custom execution strategy and let Aspire configure OracleRetryingExecutionStrategy for you
  3. Keep the custom strategy only together with DisableRetry = true

Example fix

// before
builder.EnrichOracleDatabaseDbContext<MyDbContext>(); // custom execution strategy present
// after
builder.EnrichOracleDatabaseDbContext<MyDbContext>(settings => settings.DisableRetry = true);
Defensive patterns

Strategy: validation

Validate before calling

bool hasCustomStrategy = oracleDbContextOptions.ExecutionStrategy is not null &&
    oracleDbContextOptions.ExecutionStrategy.GetType() != typeof(OracleExecutionStrategy);
if (hasCustomStrategy)
    aspireSettings.DisableRetry = true; // set before EnrichOracleDatabaseDbContext

Try / catch

try
{
    builder.EnrichOracleDatabaseDbContext<MyDbContext>();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("DisableRetry"))
{
    logger.LogError(ex, "Custom execution strategy conflicts with Aspire retry settings.");
    throw;
}

Prevention

When it happens

Trigger: Calling EnrichOracleDatabaseDbContext on a DbContext whose options carry a custom execution strategy (e.g. a custom OracleRetryingExecutionStrategy subclass or manually configured strategy) while OracleEntityFrameworkCoreSettings.DisableRetry is false/not set.

Common situations: Existing DbContexts that configured their own retry logic migrated to Aspire enrichment; subclassing OracleExecutionStrategy for custom retry policies; mixing UseOracle options with enrichment settings.

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/656cf17e45dc9160. Report an issue: GitHub.

Appendix: source

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

                        var extension = optionsBuilder.Options.FindExtension<OracleOptionsExtension>();

                        if (!settings.DisableRetry)
                        {
                            var executionStrategy = extension?.ExecutionStrategyFactory?.Invoke(new ExecutionStrategyDependencies(null!, optionsBuilder.Options, null!));

                            if (executionStrategy != null)
                            {
                                if (executionStrategy is OracleRetryingExecutionStrategy)
                                {
                                    // Keep custom Retry strategy.
                                    // Any sub-class of OracleRetryingExecutionStrategy is a valid retry strategy
                                    // which shouldn't be replaced even with DisableRetry == false
                                }
                                else if (executionStrategy.GetType() != typeof(OracleExecutionStrategy))
                                {
                                    // Check OracleExecutionStrategy specifically (no 'is'), any sub-class is treated as a custom strategy.

                                    throw new InvalidOperationException($"{nameof(OracleEntityFrameworkCoreSettings)}.{nameof(OracleEntityFrameworkCoreSettings.DisableRetry)} needs to be set when a custom Execution Strategy is configured.");
                                }
                                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)
                            {

View on GitHub (pinned to 25830f84bd)