{"record":{"id":"ac0a49ec8824c6af","repo":"OrchardCMS/OrchardCore","slug":"the-orchardcore-shells-database-configuration-section-should","errorCode":null,"errorMessage":"The 'OrchardCore.Shells.Database' configuration section should define a 'DatabaseProvider'","messagePattern":"The 'OrchardCore\\.Shells\\.Database' configuration section should define a 'DatabaseProvider'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/OrchardCore/OrchardCore.Infrastructure/Shells.Database/Extensions/DatabaseShellContextFactoryExtensions.cs","lineNumber":15,"sourceCode":"using OrchardCore.Environment.Shell;\nusing OrchardCore.Environment.Shell.Builders;\nusing OrchardCore.Environment.Shell.Descriptor.Models;\nusing OrchardCore.Shells.Database.Configuration;\n\nnamespace OrchardCore.Shells.Database.Extensions;\n\npublic static class DatabaseShellContextFactoryExtensions\n{\n    internal static Task<ShellContext> GetDatabaseContextAsync(\n        this IShellContextFactory shellContextFactory, DatabaseShellsStorageOptions options)\n    {\n        if (options.DatabaseProvider is null)\n        {\n            throw new InvalidOperationException(\"The 'OrchardCore.Shells.Database' configuration section should define a 'DatabaseProvider'\");\n        }\n\n        var settings = new ShellSettings()\n            .AsDefaultShell()\n            .AsDisposable()\n            .AsRunning();\n\n        settings[\"DatabaseProvider\"] = options.DatabaseProvider;\n        settings[\"ConnectionString\"] = options.ConnectionString;\n        settings[\"TablePrefix\"] = options.TablePrefix;\n        settings[\"Schema\"] = options.Schema;\n\n        return shellContextFactory.CreateDescribedContextAsync(settings, new ShellDescriptor());\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Infrastructure/Shells.Database/Extensions/DatabaseShellContextFactoryExtensions.cs#L1-L31","documentation":"The Database Shells storage feature requires a database provider to know which database engine stores shell configuration. When the 'OrchardCore.Shells.Database' configuration section exists but omits the 'DatabaseProvider' key, GetDatabaseContextAsync cannot construct a shell context and throws immediately. This is a fail-fast guard against an incomplete storage configuration.","triggerScenarios":"Running the app with shells storage backed by the database while appsettings.json (or env vars) has an 'OrchardCore.Shells.Database' section lacking 'DatabaseProvider', e.g. only connection string or table prefix configured.","commonSituations":"Copying a partial config snippet from docs, renaming config keys during upgrades, deploying without environment-variable overrides for DatabaseProvider, or setting up database-based shell storage for the first time.","solutions":["Add 'DatabaseProvider' under the 'OrchardCore.Shells.Database' configuration section (e.g. \"Sqlite\", \"SqlServer\", \"MySql\", \"Postgres\").","Ensure the matching database provider feature/package is referenced so the provider name resolves.","Supply the value via environment variable, e.g. OrchardCore__Shells__Database__DatabaseProvider, in containerized deployments.","Verify the loaded configuration at startup (log options.DatabaseProvider) to catch binding issues such as casing or missing section."],"exampleFix":"// before (appsettings.json)\n\"OrchardCore.Shells.Database\": {\n  \"ConnectionString\": \"...\",\n  \"TablePrefix\": \"Shell_\"\n}\n// after\n\"OrchardCore.Shells.Database\": {\n  \"DatabaseProvider\": \"Sqlite\",\n  \"ConnectionString\": \"...\",\n  \"TablePrefix\": \"Shell_\"\n}","handlingStrategy":"validation","validationCode":"var section = config.GetSection(\"OrchardCore.Shells.Database\");\nif (section.Exists() && string.IsNullOrEmpty(section[\"DatabaseProvider\"]))\n    throw new InvalidOperationException(\"OrchardCore.Shells.Database requires DatabaseProvider\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set DatabaseProvider alongside ConnectionString in the shells database section","Validate shell storage config in CI before deployment","Use strongly typed options binding and validate on startup"],"tags":["configuration","shell-storage","startup","database"],"backgroundTag":"missing-required-config-field","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"}