OrchardCMS/OrchardCore · critical · ArgumentException

Unknown database provider:

Error message

Unknown database provider: 

What it means

AddDataAccess configures YesSql's store based on the tenant's DatabaseProvider shell setting via a switch statement. The default arm throws ArgumentException("Unknown database provider: <value>") for any provider other than SqlConnection, MySql, Sqlite, or Postgres. This happens when building the tenant shell, so the tenant cannot start.

Solutions

  1. Set DatabaseProvider to exactly one of: SqlConnection, MySql, Sqlite, Postgres in the tenant's shell settings file.
  2. If the tenant is mid-setup, re-run setup and choose a supported database provider in the wizard.
  3. Validate the config programmatically (compare against DatabaseProviderValue constants) before starting the shell.

Example fix

// before
shellSettings["DatabaseProvider"] = "postgresql";
// after
shellSettings["DatabaseProvider"] = DatabaseProviderValue.Postgres;
Defensive patterns

Strategy: validation

Validate before calling

var provider = shellSettings["DatabaseProvider"];
var allowed = new[] { "SqlConnection", "MySql", "Sqlite", "Postgres" };
if (string.IsNullOrWhiteSpace(provider) || !allowed.Contains(provider))
    throw new InvalidOperationException($"Invalid DatabaseProvider '{provider}' in tenant settings");

Try / catch

catch (ArgumentException ex) { logger.LogCritical(ex, "Shell startup failed: unknown database provider"); throw; }

Prevention

When it happens

Trigger: Booting a tenant whose shellSettings["DatabaseProvider"] is not one of the four supported values — e.g., empty string, "none", "oracle", or a legacy provider name in App_Data/Sites/*/appsettings.json.

Common situations: Provisioning tenants programmatically with a typo'd provider; copying tenant config between environments where a provider was renamed; deleting the DatabaseProvider key so it reads null.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/1492b386b2088190. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs:101

                        var connectionString = SqliteHelper.GetConnectionString(sqliteOptions, databaseFolder, shellSettings);

                        storeConfiguration
                            .UseSqLite(connectionString, yesSqlOptions.IsolationLevel)
                            .UseDefaultIdGenerator();
                        break;
                    case DatabaseProviderValue.MySql:
                        storeConfiguration
                            .UseMySql(shellSettings["ConnectionString"], yesSqlOptions.IsolationLevel, shellSettings["Schema"])
                            .UseBlockIdGenerator();
                        break;
                    case DatabaseProviderValue.Postgres:
                        storeConfiguration
                            .UsePostgreSql(shellSettings["ConnectionString"], yesSqlOptions.IsolationLevel, shellSettings["Schema"])
                            .UseBlockIdGenerator();
                        break;
                    default:
                        throw new ArgumentException("Unknown database provider: " + shellSettings["DatabaseProvider"]);
                }

                if (!string.IsNullOrWhiteSpace(shellSettings["TablePrefix"]))
                {
                    var tablePrefix = shellSettings["TablePrefix"].Trim() + databaseTableOptions.TableNameSeparator;

                    storeConfiguration.SetTablePrefix(tablePrefix);
                }

                var store = StoreFactory.Create(storeConfiguration);

                var indexes = sp.GetServices<IIndexProvider>();

                store.RegisterIndexes(indexes);

                return store;
            });

View on GitHub (pinned to 4306c0717f)