{"record":{"id":"a7b323424dd1322f","repo":"dotnet/orleans","slug":"invalid-nameof-adonetstreamoptions-values-for-a-a7b323","errorCode":null,"errorMessage":"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': configure exactly one of {nameof(options.ConnectionString)} or {nameof(options.DataSource)}.","messagePattern":"Invalid (.+?) values for ADO\\.NET Streaming Provider '(.+?)': configure exactly one of (.+?) or (.+?)\\.","errorType":"validation","errorClass":"OrleansConfigurationException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptionsValidator.cs","lineNumber":20,"sourceCode":"\nnamespace Orleans.Configuration;\n\n/// <summary>\n/// Validates <see cref=\"AdoNetStreamOptions\"/> configuration.\n/// </summary>\npublic class AdoNetStreamOptionsValidator(AdoNetStreamOptions options, string name) : IConfigurationValidator\n{\n    /// <inheritdoc />\n    public void ValidateConfiguration()\n    {\n        if (IsNullOrWhiteSpace(options.Invariant))\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.Invariant)} is required.\");\n        }\n\n        if (IsNullOrWhiteSpace(options.ConnectionString) == (options.DataSource is null))\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': configure exactly one of {nameof(options.ConnectionString)} or {nameof(options.DataSource)}.\");\n        }\n\n        if (options.MaxAttempts < 0)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.MaxAttempts)} must be greater than zero.\");\n        }\n\n        if (options.VisibilityTimeout < TimeSpan.Zero)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.VisibilityTimeout)} must be greater than zero.\");\n        }\n\n        if (options.EvictionInterval < TimeSpan.Zero)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionInterval)} must be greater than zero.\");\n        }\n\n        if (options.ExpiryTimeout < TimeSpan.Zero)","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptionsValidator.cs#L2-L38","documentation":"Thrown by the ADO.NET streaming options validator when both ConnectionString and DataSource are set, or neither is. The stream provider needs exactly one connection source per named provider. The equality check fires for both the all-unset and both-set cases.","triggerScenarios":"ValidateConfiguration() runs on AdoNetStreamOptions where IsNullOrWhiteSpace(ConnectionString) equals (DataSource is null). Occurs when only Invariant is set, or when both a ConnectionString and DbDataSource are supplied for the same provider name.","commonSituations":"Configuring the provider with Invariant but no connection; supplying a ConnectionString while also injecting a DbDataSource for pooling; mid-migration leaving both populated.","solutions":["Provide exactly one of options.ConnectionString or options.DataSource per provider.","Remove the redundant field if migrating between the two.","Confirm the appsettings.json stream-provider section has exactly one connection field."],"exampleFix":"// before\nbuilder.AddAdoNetStreams(\"ads\", o =>\n{\n    o.Invariant = AdoNetInvariants.InvariantNameSqlServer;\n});\n\n// after\nbuilder.AddAdoNetStreams(\"ads\", o =>\n{\n    o.Invariant = AdoNetInvariants.InvariantNameSqlServer;\n    o.ConnectionString = \"Server=.;Database=Orleans;Trusted_Connection=True;\";\n});","handlingStrategy":"validation","validationCode":"static void CheckStreamConnection(AdoNetStreamOptions 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 per stream provider.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use one connection strategy per provider and document it.","Add a startup assertion for exactly-one connection source per provider name.","Remove the redundant field atomically during migration."],"tags":["configuration","adonet","streaming","connection-string","startup-validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}