dotnet/orleans · error · InvalidOperationException

Database provider factory with '{invariantName}' invariant n

Error message

Database provider factory with '{invariantName}' invariant name not supported.

What it means

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.

Source

Thrown at src/AdoNet/Shared/Storage/DbConnectionFactory.cs:50

            {
                { AdoNetInvariants.InvariantNameSqlServer, new List<Tuple<string, string>>{ new Tuple<string, string>("Microsoft.Data.SqlClient", "Microsoft.Data.SqlClient.SqlClientFactory") } },
                { AdoNetInvariants.InvariantNameMySql, new List<Tuple<string, string>>{ new Tuple<string, string>("MySql.Data", "MySql.Data.MySqlClient.MySqlClientFactory") } },
                { AdoNetInvariants.InvariantNameOracleDatabase, new List<Tuple<string, string>>{ new Tuple<string, string>("Oracle.ManagedDataAccess", "Oracle.ManagedDataAccess.Client.OracleClientFactory") } },
                { AdoNetInvariants.InvariantNamePostgreSql, new List<Tuple<string, string>>{ new Tuple<string, string>("Npgsql", "Npgsql.NpgsqlFactory") } },
                { AdoNetInvariants.InvariantNameSqlLite, new List<Tuple<string, string>>{ new Tuple<string, string>("Microsoft.Data.Sqlite", "Microsoft.Data.Sqlite.SqliteFactory") } },
                { AdoNetInvariants.InvariantNameMySqlConnector, new List<Tuple<string, string>>{ new Tuple<string, string>("MySqlConnector", "MySqlConnector.MySqlConnectorFactory") , new Tuple<string, string>("MySqlConnector", "MySql.Data.MySqlClient.MySqlClientFactory") } },
            };

        private static CachedFactory GetFactory(string invariantName)
        {
            if (string.IsNullOrWhiteSpace(invariantName))
            {
                throw new ArgumentNullException(nameof(invariantName));
            }

            List<Tuple<string, string>>? providerFactoryDefinitions;
            if (!providerFactoryTypeMap.TryGetValue(invariantName, out providerFactoryDefinitions) || providerFactoryDefinitions.Count == 0)
                throw new InvalidOperationException($"Database provider factory with '{invariantName}' invariant name not supported.");

            List<Exception>? exceptions = null;
            foreach (var providerFactoryDefinition in providerFactoryDefinitions)
            {
                Assembly? asm = null;
                try
                {
                    var asmName = new AssemblyName(providerFactoryDefinition.Item1);
                    asm = Assembly.Load(asmName);
                }
                catch (Exception exc)
                {
                    AddException(new InvalidOperationException($"Unable to find and/or load a candidate assembly '{providerFactoryDefinition.Item1}' for '{invariantName}' invariant name.", exc));
                    continue;
                }

                if (asm == null)
                {

View on GitHub (pinned to fca799fa70)

Solutions

  1. Use one of the exact invariant strings defined in Orleans.Clustering.AdoNet.Storage.AdoNetInvariants (e.g. InvariantNameSqlServer = 'Microsoft.Data.SqlClient').
  2. If you need a connector Orleans does not ship support for, fork or extend the providerFactoryTypeMap rather than passing an arbitrary invariant.
  3. Double-check spelling and casing of the invariant in your configuration source.

Example fix

// before
options.Invariant = "System.Data.SqlClient"; // legacy, not in the map

// after
options.Invariant = "Microsoft.Data.SqlClient";
Defensive patterns

Strategy: validation

Validate before calling

var supported = new HashSet<string>(AdoNetInvariants.Invariants);
if (!supported.Contains(options.Invariant))
    throw new InvalidOperationException($"Invariant '{options.Invariant}' is not supported. Use one of: {string.Join(", ", supported)}");

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/c1d0ec38aa805b71. Report an issue: GitHub.