{"record":{"id":"4fe87e755e832152","repo":"OrchardCMS/OrchardCore","slug":"unsupported-database-provider","errorCode":null,"errorMessage":"Unsupported database provider","messagePattern":"Unsupported database provider","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"critical","filePath":"src/OrchardCore/OrchardCore.Data.YesSql/DbConnectionValidator.cs","lineNumber":202,"sourceCode":"        sqlBuilder.Take(\"1\");\n\n        if (isShellDescriptorDocument)\n        {\n            sqlBuilder.WhereAnd($\"Type = '{s_shellDescriptorTypeColumnValue}'\");\n        }\n\n        return sqlBuilder.ToSqlString();\n    }\n\n    private static (IConnectionFactory connectionFactory, ISqlDialect sqlDialect) GetFactoryAndSqlDialect(\n        string databaseProvider,\n        string connectionString) => databaseProvider switch\n        {\n            DatabaseProviderValue.SqlConnection => (new DbConnectionFactory<SqlConnection>(connectionString), new SqlServerDialect()),\n            DatabaseProviderValue.MySql => (new DbConnectionFactory<MySqlConnection>(connectionString), new MySqlDialect()),\n            DatabaseProviderValue.Sqlite => (new DbConnectionFactory<SqliteConnection>(connectionString), new SqliteDialect()),\n            DatabaseProviderValue.Postgres => (new DbConnectionFactory<NpgsqlConnection>(connectionString), new PostgreSqlDialect()),\n            _ => throw new ArgumentOutOfRangeException(nameof(databaseProvider), \"Unsupported database provider\"),\n        };\n\n    private static SqlBuilder GetSqlBuilder(ISqlDialect sqlDialect, string tablePrefix, string tableNameSeparator)\n    {\n        var prefix = string.Empty;\n        if (!string.IsNullOrWhiteSpace(tablePrefix))\n        {\n            prefix = tablePrefix.Trim() + tableNameSeparator;\n        }\n\n        return new SqlBuilder(prefix, sqlDialect);\n    }\n}\n","sourceCodeStart":184,"sourceCodeEnd":216,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Data.YesSql/DbConnectionValidator.cs#L184-L216","documentation":"DbConnectionValidator.GetFactoryAndSqlDialect maps a DatabaseProviderValue to a concrete ADO.NET connection factory plus YesSql SQL dialect via a switch expression. The default arm throws ArgumentOutOfRangeException(\"Unsupported database provider\") when the provider value does not match any of the four supported providers (SqlConnection, MySql, Sqlite, Postgres). This runs during tenant validation (ValidateAsync) before the shell is built, so an unrecognized provider string aborts tenant setup.","triggerScenarios":"Calling ValidateAsync (GetFactoryAndSqlDialect) with a DatabaseProviderValue other than SqlConnection/MySql/Sqlite/Postgres — typically a raw string like \"sqlserver\", \"mssql\", or an empty/garbage value in tenant appsettings under DatabaseProvider.","commonSituations":"Hand-edited tenant configuration (appsites/*.json) with a misspelled provider name; a provider casing/label change across Orchard Core versions; copy-pasting config from another CMS that names providers differently.","solutions":["Set the tenant's DatabaseProvider in shell settings to one of the exact values the switch handles: SqlConnection, MySql, Sqlite, or Postgres.","Verify the value stored in App_Data/Sites/{tenant}/appsettings.json (or the tenant's DatabaseProvider shell setting) has no typos, extra whitespace, or different casing.","If you programmatically set shell settings for tenant provisioning, use the DatabaseProviderValue constants instead of raw strings."],"exampleFix":"// before\n\"DatabaseProvider\": \"sqlserver\"\n// after\n\"DatabaseProvider\": \"SqlConnection\"","handlingStrategy":"validation","validationCode":"var supported = new[] { \"SqlConnection\", \"MySql\", \"Sqlite\", \"Postgres\" };\nif (!supported.Contains(shellSettings[\"DatabaseProvider\"]))\n    throw new InvalidOperationException($\"Provider '{shellSettings[\"DatabaseProvider\"]}' is not supported. Use one of: {string.Join(\", \", supported)}\");","typeGuard":null,"tryCatchPattern":"catch (ArgumentOutOfRangeException ex) { logger.LogError(ex, \"Tenant {Tenant} has an unsupported database provider\", tenant); return ValidationFailed; }","preventionTips":["Only set DatabaseProvider from the DatabaseProviderValue constants, never raw strings","Lint/validate tenant shell settings files on deployment","Pick providers from the setup wizard dropdown instead of hand-editing config"],"tags":["database","configuration","argument-out-of-range"],"backgroundTag":"unsupported-enum-value","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}