{"record":{"id":"42ed214d78479ce9","repo":"microsoft/aspire","slug":"conflicting-values-for-commandtimeout-were-found-in-nameof-42ed21","errorCode":null,"errorMessage":"Conflicting values for 'CommandTimeout' were found in {nameof(PomeloEntityFrameworkCoreMySqlSettings)} and set in DbContextOptions<{typeof(TContext).Name}>.","messagePattern":"Conflicting values for 'CommandTimeout' were found in (.+?) and set in DbContextOptions<(.+?)>\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/AspireEFMySqlExtensions.cs","lineNumber":228,"sourceCode":"                                }\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                            {\n                                throw new InvalidOperationException($\"Conflicting values for 'CommandTimeout' were found in {nameof(PomeloEntityFrameworkCoreMySqlSettings)} and set in DbContextOptions<{typeof(TContext).Name}>.\");\n                            }\n\n                            options.CommandTimeout(settings.CommandTimeout);\n                        }\n\n                    });\n                }\n            }\n#pragma warning restore EF1001 // Internal EF Core API usage.\n        }\n    }\n\n    private static void ConfigureInstrumentation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] TContext>(IHostApplicationBuilder builder, PomeloEntityFrameworkCoreMySqlSettings settings) where TContext : DbContext\n    {\n        if (!settings.DisableHealthChecks)\n        {\n            // calling MapHealthChecks is the responsibility of the app, not Component\n            builder.TryAddHealthCheck(","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Pomelo.EntityFrameworkCore.MySql/AspireEFMySqlExtensions.cs#L210-L246","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nbuilder.AddMySqlDbContext<MyDbContext>(connectionName);\n// appsettings: PomeloEntityFrameworkCoreMySql:CommandTimeout = 30\n// DbContextOptions already: options.CommandTimeout = 60\n\n// after\nbuilder.AddEnrichMySqlDbContext<MyDbContext>(connectionName, settings => settings.CommandTimeout = 60); // match existing value","handlingStrategy":"validation","validationCode":"var configuredTimeout = new DbContextOptionsBuilder<TContext>().Options.CommandTimeout;\nif (settings.CommandTimeout is int t && configuredTimeout is int ct && t != ct)\n    throw new InvalidOperationException($\"CommandTimeout mismatch: settings={t}, options={ct}\");","typeGuard":null,"tryCatchPattern":"try { builder.EnrichMySqlDbContext<TContext>(name); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"CommandTimeout\"))\n{ /* unify the value in one place and retry/enrich */ }","preventionTips":["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."],"tags":["entity-framework-core","mysql","command-timeout","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-21T04:17:39.646Z"}