{"record":{"id":"7660648d1f5a5a7b","repo":"dotnet/orleans","slug":"invalid-nameof-adonetclusteringsilooptions-valu-766064","errorCode":null,"errorMessage":"Invalid {nameof(AdoNetClusteringSiloOptions)} values for {nameof(AdoNetClusteringTable)}. Configure exactly one of {nameof(options.ConnectionString)} or {nameof(options.DataSource)}.","messagePattern":"Invalid (.+?) values for (.+?)\\. Configure exactly one of (.+?) or (.+?)\\.","errorType":"validation","errorClass":"OrleansConfigurationException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Orleans.Clustering.AdoNet/Options/AdoNetReminderTableOptionsValidator.cs","lineNumber":29,"sourceCode":"    {\n        private readonly AdoNetClusteringSiloOptions options;\n\n        public AdoNetClusteringSiloOptionsValidator(IOptions<AdoNetClusteringSiloOptions> options)\n        {\n            this.options = options.Value;\n        }\n\n        /// <inheritdoc />\n        public void ValidateConfiguration()\n        {\n            if (string.IsNullOrWhiteSpace(this.options.Invariant))\n            {\n                throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetClusteringSiloOptions)} values for {nameof(AdoNetClusteringTable)}. {nameof(options.Invariant)} is required.\");\n            }\n\n            if (string.IsNullOrWhiteSpace(this.options.ConnectionString) == (this.options.DataSource is null))\n            {\n                throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetClusteringSiloOptions)} values for {nameof(AdoNetClusteringTable)}. Configure exactly one of {nameof(options.ConnectionString)} or {nameof(options.DataSource)}.\");\n            }\n        }\n    }\n}","sourceCodeStart":11,"sourceCodeEnd":33,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Orleans.Clustering.AdoNet/Options/AdoNetReminderTableOptionsValidator.cs#L11-L33","documentation":"Thrown by the ADO.NET clustering configuration validator when both ConnectionString and DataSource are set, or when neither is set. AdoNetClusteringTable needs exactly one connection source to open a database connection. The check `IsNullOrWhiteSpace(ConnectionString) == (DataSource is null)` is true (and throws) in both the all-empty and both-set cases.","triggerScenarios":"Calling ValidateConfiguration() (run by the silo host at startup) on AdoNetClusteringSiloOptions when ConnectionString is blank AND DataSource is null, or when a ConnectionString is supplied AND a DbDataSource is also supplied. Triggered via AddAdoNetClustering / UseAdoNetClustering registration paths.","commonSituations":"Forgetting the connection string in appsettings.json under the clustering section; supplying only an Invariant with no connection info; or migrating from ConnectionString to DbDataSource and leaving the old ConnectionString populated so both resolve.","solutions":["Set exactly one of options.ConnectionString or options.DataSource in the clustering configuration.","If migrating to DbDataSource, remove the now-redundant ConnectionString value.","If using appsettings.json, ensure the clustering config section contains a non-blank ConnectionString and no DataSource (or vice-versa)."],"exampleFix":"// before\nbuilder.UseAdoNetClustering(options =>\n{\n    options.Invariant = AdoNetInvariants.InvariantNameSqlServer;\n    // both unset -> error\n});\n\n// after\nbuilder.UseAdoNetClustering(options =>\n{\n    options.Invariant = AdoNetInvariants.InvariantNameSqlServer;\n    options.ConnectionString = \"Server=.;Database=Orleans;Trusted_Connection=True;\";\n});","handlingStrategy":"validation","validationCode":"// Run before host start to fail fast with a clearer message.\nstatic void CheckClustering(AdoNetClusteringSiloOptions o)\n{\n    var exactlyOne = string.IsNullOrWhiteSpace(o.ConnectionString) != (o.DataSource is null);\n    if (!exactlyOne)\n        throw new InvalidOperationException(\"Set exactly one of ConnectionString or DataSource for clustering.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize all ADO.NET connection setup in one Configure delegate per subsystem.","Add a startup health check that asserts exactly one connection source before Build().","When migrating ConnectionString -> DataSource, delete the old value in the same commit."],"tags":["configuration","adonet","clustering","connection-string","startup-validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}