{"record":{"id":"95ba156757be5282","repo":"microsoft/aspire","slug":"nameof-pomeloentityframeworkcoremysqlsettings-nameof","errorCode":null,"errorMessage":"{nameof(PomeloEntityFrameworkCoreMySqlSettings)}.{nameof(PomeloEntityFrameworkCoreMySqlSettings.DisableRetry)} needs to be set when a custom Execution Strategy is configured.","messagePattern":"(.+?)\\.(.+?) needs to be set when a custom Execution Strategy is configured\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/AspireEFMySqlExtensions.cs","lineNumber":209,"sourceCode":"                        var extension = optionsBuilder.Options.FindExtension<MySqlOptionsExtension>();\n\n                        if (!settings.DisableRetry)\n                        {\n                            var executionStrategy = extension?.ExecutionStrategyFactory?.Invoke(new ExecutionStrategyDependencies(null!, optionsBuilder.Options, null!));\n\n                            if (executionStrategy != null)\n                            {\n                                if (executionStrategy is MySqlRetryingExecutionStrategy)\n                                {\n                                    // Keep custom Retry strategy.\n                                    // Any sub-class of MySqlRetryingExecutionStrategy is a valid retry strategy\n                                    // which shouldn't be replaced even with DisableRetry == false\n                                }\n                                else if (executionStrategy.GetType() != typeof(MySqlExecutionStrategy))\n                                {\n                                    // Check MySqlExecutionStrategy specifically (no 'is'), any sub-class is treated as a custom strategy.\n\n                                    throw new InvalidOperationException($\"{nameof(PomeloEntityFrameworkCoreMySqlSettings)}.{nameof(PomeloEntityFrameworkCoreMySqlSettings.DisableRetry)} needs to be set when a custom Execution Strategy is configured.\");\n                                }\n                                else\n                                {\n                                    options.EnableRetryOnFailure();\n                                }\n                            }\n                            else\n                            {\n                                options.EnableRetryOnFailure();\n                            }\n                        }\n\n                        if (settings.CommandTimeout.HasValue)\n                        {\n                            if (extension != null &&\n                                extension.CommandTimeout.HasValue &&\n                                extension.CommandTimeout != settings.CommandTimeout)\n                            {","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/AspireEFMySqlExtensions.cs#L191-L227","documentation":"Aspire's MySQL EF enrichment replaces the default retry execution strategy with its own MySqlExecutionStrategy when EnableRetry is on. If the DbContext was configured with a custom execution strategy (any subclass of ExecutionStrategy other than MySqlExecutionStrategy), Aspire refuses to silently discard it. Setting DisableRetry tells Aspire you accept keeping the custom strategy instead.","triggerScenarios":"Calling AddEnrichMySqlDbContext (or EnrichMySqlDbContext) with PomeloEntityFrameworkCoreMySqlSettings.DisableRetry = false (default) while the DbContextOptions already have a custom ExecutionStrategy registered (e.g. via options.ExecutionStrategy(...) or a MySqlExecutionStrategy subclass).","commonSituations":"Apps that previously registered a custom retry strategy (custom backoff, fault-injection strategy for tests, k8s-aware retry) then adopt Aspire's enrichment; migration from manual Pomelo setup to Aspire hosting while keeping old strategy code.","solutions":["Set DisableRetry = true in PomeloEntityFrameworkCoreMySqlSettings so Aspire leaves your custom execution strategy in place.","Remove the custom execution strategy registration if you want Aspire's built-in MySqlExecutionStrategy retry (EnableRetryOnFailure) instead.","Align strategies: wrap your custom logic in a class derived so that it is intentionally chosen, and keep DisableRetry = true, documenting why."],"exampleFix":"// before\nbuilder.EnrichMySqlDbContext<MyDbContext>(settings => settings.DisableRetry = false);\noptionsBuilder.ExecutionStrategy(ctx => new CustomExecutionStrategy(ctx, 5));\n\n// after\nbuilder.EnrichMySqlDbContext<MyDbContext>(settings => settings.DisableRetry = true); // keep custom strategy\n// OR remove CustomExecutionStrategy and let Aspire enable MySqlExecutionStrategy retry","handlingStrategy":"validation","validationCode":"if (!settings.DisableRetry && options.ExecutionStrategy != null)\n    throw new InvalidOperationException(\"Set DisableRetry = true before enriching a DbContext with a custom execution strategy.\");","typeGuard":null,"tryCatchPattern":"try { builder.EnrichMySqlDbContext<TContext>(name, settings); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"DisableRetry\"))\n{ /* log guidance: either disable retry or remove custom strategy */ }","preventionTips":["Keep custom execution strategies and Aspire enrichment mutually exclusive by design decision, documented in the repo.","Default DisableRetry to true in team settings templates when custom strategies are standard.","Add an integration test that enriches each DbContext with production options to catch conflicts at startup."],"tags":["entity-framework-core","mysql","retry-strategy","configuration-conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}