{"record":{"id":"43ca65dc00e76aaa","repo":"dotnet/orleans","slug":"the-name-of-invariant-must-contain-characters","errorCode":null,"errorMessage":"The name of invariant must contain characters","messagePattern":"The name of invariant must contain characters","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Shared/Storage/RelationalStorage.cs","lineNumber":98,"sourceCode":"        {\n            get\n            {\n                return _connectionString;\n            }\n        }\n\n\n        /// <summary>\n        /// Creates an instance of a database of type <see cref=\"IRelationalStorage\"/>.\n        /// </summary>\n        /// <param name=\"invariantName\">The invariant name of the connector for this database.</param>\n        /// <param name=\"connectionString\">The connection string this database should use for database operations.</param>\n        /// <returns></returns>\n        public static IRelationalStorage CreateInstance(string invariantName, string connectionString)\n        {\n            if (string.IsNullOrWhiteSpace(invariantName))\n            {\n                throw new ArgumentException(\"The name of invariant must contain characters\", nameof(invariantName));\n            }\n\n            if (string.IsNullOrWhiteSpace(connectionString))\n            {\n                throw new ArgumentException(\"Connection string must contain characters\", nameof(connectionString));\n            }\n\n            return new RelationalStorage(invariantName, connectionString);\n        }\n\n        /// <summary>\n        /// Creates an instance of a database of type <see cref=\"IRelationalStorage\"/>.\n        /// </summary>\n        /// <param name=\"invariantName\">The invariant name of the connector for this database.</param>\n        /// <param name=\"dataSource\">The data source used to open database connections.</param>\n        /// <returns>A relational storage instance.</returns>\n        public static IRelationalStorage CreateInstance(string invariantName, DbDataSource dataSource)\n        {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Shared/Storage/RelationalStorage.cs#L80-L116","documentation":"Thrown by RelationalStorage.CreateInstance(string invariantName, string connectionString) when invariantName is null, empty, or whitespace. The invariant name (e.g. 'System.Data.SqlClient') selects the ADO.NET provider via DbProviderFactories, so a blank value cannot resolve a factory. This is a startup/configuration ArgumentException with the offending parameter named.","triggerScenarios":"Calling IRelationalStorage storage = RelationalStorage.CreateInstance(invariantName, connectionString) with a missing/blank invariant. Common when the invariant is read from a config section, environment variable, or options object that was not bound.","commonSituations":"Misconfigured Orleans AdoNet provider options (AdoNetInvariantName left empty); wrong casing/typo in the invariant string; options binding skipped so the property defaults to null; CI deploy using a different config file than local.","solutions":["Set the invariant name in your silo/client configuration, e.g. AdoNetInvariantName = \"System.Data.SqlClient\" or the MySql/Oracle/Npgsql invariant.","Verify the string is non-empty after config binding; log it at startup before calling CreateInstance.","Use the 3-argument CreateInstance overload only if you intend to pass a DbDataSource; otherwise ensure invariantName is set.","Confirm the chosen invariant is registered with DbProviderFactories in your runtime."],"exampleFix":"// before\nvar storage = RelationalStorage.CreateInstance(\"\", connectionString);\n\n// after\nvar storage = RelationalStorage.CreateInstance(\"System.Data.SqlClient\", connectionString);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(invariantName))\n    throw new InvalidOperationException(\"ADO.NET invariant name is not configured.\");","typeGuard":"static bool IsValidInvariant(string? s) => !string.IsNullOrWhiteSpace(s);","tryCatchPattern":"try { storage = RelationalStorage.CreateInstance(invariant, cs); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(invariant)) { /* fix config */ }","preventionTips":["Bind and log the invariant name at startup before constructing storage.","Keep provider invariant in a single config source of truth.","Add an options validator that rejects blank invariant names."],"tags":["csharp","dotnet","orleans","adonet","configuration","argument-validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}