{"record":{"id":"c1d0ec38aa805b71","repo":"dotnet/orleans","slug":"database-provider-factory-with-invariantname-i","errorCode":null,"errorMessage":"Database provider factory with '{invariantName}' invariant name not supported.","messagePattern":"Database provider factory with '(.+?)' invariant name not supported\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Shared/Storage/DbConnectionFactory.cs","lineNumber":50,"sourceCode":"            {\n                { AdoNetInvariants.InvariantNameSqlServer, new List<Tuple<string, string>>{ new Tuple<string, string>(\"Microsoft.Data.SqlClient\", \"Microsoft.Data.SqlClient.SqlClientFactory\") } },\n                { AdoNetInvariants.InvariantNameMySql, new List<Tuple<string, string>>{ new Tuple<string, string>(\"MySql.Data\", \"MySql.Data.MySqlClient.MySqlClientFactory\") } },\n                { AdoNetInvariants.InvariantNameOracleDatabase, new List<Tuple<string, string>>{ new Tuple<string, string>(\"Oracle.ManagedDataAccess\", \"Oracle.ManagedDataAccess.Client.OracleClientFactory\") } },\n                { AdoNetInvariants.InvariantNamePostgreSql, new List<Tuple<string, string>>{ new Tuple<string, string>(\"Npgsql\", \"Npgsql.NpgsqlFactory\") } },\n                { AdoNetInvariants.InvariantNameSqlLite, new List<Tuple<string, string>>{ new Tuple<string, string>(\"Microsoft.Data.Sqlite\", \"Microsoft.Data.Sqlite.SqliteFactory\") } },\n                { AdoNetInvariants.InvariantNameMySqlConnector, new List<Tuple<string, string>>{ new Tuple<string, string>(\"MySqlConnector\", \"MySqlConnector.MySqlConnectorFactory\") , new Tuple<string, string>(\"MySqlConnector\", \"MySql.Data.MySqlClient.MySqlClientFactory\") } },\n            };\n\n        private static CachedFactory GetFactory(string invariantName)\n        {\n            if (string.IsNullOrWhiteSpace(invariantName))\n            {\n                throw new ArgumentNullException(nameof(invariantName));\n            }\n\n            List<Tuple<string, string>>? providerFactoryDefinitions;\n            if (!providerFactoryTypeMap.TryGetValue(invariantName, out providerFactoryDefinitions) || providerFactoryDefinitions.Count == 0)\n                throw new InvalidOperationException($\"Database provider factory with '{invariantName}' invariant name not supported.\");\n\n            List<Exception>? exceptions = null;\n            foreach (var providerFactoryDefinition in providerFactoryDefinitions)\n            {\n                Assembly? asm = null;\n                try\n                {\n                    var asmName = new AssemblyName(providerFactoryDefinition.Item1);\n                    asm = Assembly.Load(asmName);\n                }\n                catch (Exception exc)\n                {\n                    AddException(new InvalidOperationException($\"Unable to find and/or load a candidate assembly '{providerFactoryDefinition.Item1}' for '{invariantName}' invariant name.\", exc));\n                    continue;\n                }\n\n                if (asm == null)\n                {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Shared/Storage/DbConnectionFactory.cs#L32-L68","documentation":"Thrown by DbConnectionFactory.GetFactory when the supplied ADO.NET invariant name is not one of the six recognized entries in the internal providerFactoryTypeMap. Orleans only knows how to load connectors for SQL Server, Oracle, SQLite, MySQL (MySql.Data), PostgreSQL (Npgsql), and MySqlConnector. Any other string is treated as unsupported and rejected before any assembly load is attempted.","triggerScenarios":"Passing an invariantName to DbConnectionFactory.CreateConnection or ValidateDataSource that is not one of: 'Microsoft.Data.SqlClient', 'Oracle.DataAccess.Client', 'System.Data.SQLite', 'MySql.Data.MySqlClient', 'Npgsql', 'MySql.Data.MySqlConnector'. Also reached when AdoNetStreamOptions.Invariant (or the clustering/reminders/persistence equivalent) is misspelled or uses a deprecated string.","commonSituations":"Using the obsolete 'System.Data.SqlClient' instead of 'Microsoft.Data.SqlClient'; typing 'PostgreSQL' or 'postgres' instead of 'Npgsql'; referencing a connector whose invariant differs from the registered constant (e.g. an unofficial MySQL fork).","solutions":["Use one of the exact invariant strings defined in Orleans.Clustering.AdoNet.Storage.AdoNetInvariants (e.g. InvariantNameSqlServer = 'Microsoft.Data.SqlClient').","If you need a connector Orleans does not ship support for, fork or extend the providerFactoryTypeMap rather than passing an arbitrary invariant.","Double-check spelling and casing of the invariant in your configuration source."],"exampleFix":"// before\noptions.Invariant = \"System.Data.SqlClient\"; // legacy, not in the map\n\n// after\noptions.Invariant = \"Microsoft.Data.SqlClient\";","handlingStrategy":"validation","validationCode":"var supported = new HashSet<string>(AdoNetInvariants.Invariants);\nif (!supported.Contains(options.Invariant))\n    throw new InvalidOperationException($\"Invariant '{options.Invariant}' is not supported. Use one of: {string.Join(\", \", supported)}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always reference the invariant via the AdoNetInvariants constants instead of literal strings.","Document the supported invariants next to your configuration helper.","Fail fast in your bootstrap code with a clearer message than the internal one."],"tags":["adonet","configuration","database","invariant","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}