{"record":{"id":"f0c27dd5ee83bd20","repo":"elsa-workflows/elsa-core","slug":"connection-string-not-configured-for-featurename-either","errorCode":null,"errorMessage":"Connection string not configured for {featureName}. Either configure the feature directly or provide shared settings via the combined persistence feature.","messagePattern":"Connection string not configured for (.+?)\\. Either configure the feature directly or provide shared settings via the combined persistence feature\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/modules/Elsa.Persistence.EFCore.Common/PersistenceShellFeatureBase.cs","lineNumber":67,"sourceCode":"    protected virtual Action<IServiceProvider, DbContextOptionsBuilder> DbContextOptionsBuilder { get; set; } = (_, _) => { };\n    \n    public void ConfigureServices(IServiceCollection services)\n    {\n        // Capture feature-specific settings\n        var featureConnectionString = ConnectionString;\n        var featureDbContextOptions = DbContextOptions;\n        var featureUseContextPooling = UseContextPooling;\n        var featureRunMigrations = RunMigrations;\n        var featureDbContextFactoryLifetime = DbContextFactoryLifetime;\n\n        // Resolve effective settings at runtime, falling back to shared settings\n        Action<IServiceProvider, DbContextOptionsBuilder> setup = (sp, opts) =>\n        {\n            var sharedSettings = sp.GetService<IOptions<SharedPersistenceSettings>>()?.Value;\n            \n            var connectionString = featureConnectionString \n                ?? sharedSettings?.ConnectionString\n                ?? throw new InvalidOperationException(\n                    $\"Connection string not configured for {GetType().Name}. \" +\n                    $\"Either configure the feature directly or provide shared settings via the combined persistence feature.\");\n            \n            var dbContextOptions = featureDbContextOptions ?? sharedSettings?.DbContextOptions;\n\n            opts.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning));\n\n            // Configure the database provider\n            var migrationsAssembly = GetMigrationsAssembly();\n            ConfigureProvider(opts, migrationsAssembly, connectionString, dbContextOptions);\n\n            // Allow derived classes to further configure\n            DbContextOptionsBuilder(sp, opts);\n        };\n\n        // Resolve pooling and lifetime settings with fallback\n        // Note: These are resolved at configuration time, not runtime, but they'll use defaults if not set\n        var useContextPooling = featureUseContextPooling ?? false;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Persistence.EFCore.Common/PersistenceShellFeatureBase.cs#L49-L85","documentation":"PersistenceShellFeatureBase resolves the connection string at feature configuration time as: feature-specific connection string, then SharedPersistenceSettings.ConnectionString, else it throws. This guards against a DbContext being registered with no way to connect. The message names the concrete feature type so you know which feature lacked configuration.","triggerScenarios":"Registering an EF Core persistence feature (e.g. Runflows/Management/Runtime EF Core persistence features) without calling its ConfigureFeature with a connection string, and without setting ElsaOptions/SharedPersistenceSettings.ConnectionString via the combined persistence feature.","commonSituations":"Migrating from SQLite/other modules to EF Core persistence and forgetting connection strings; only some features configured directly while the combined shared persistence feature is absent; reading the connection string from environment/config that is empty in a given environment (CI, container); calling Add EF persistence features in the wrong order so shared settings aren't registered.","solutions":["Configure the shared connection string once via the combined EF Core persistence feature (SharedPersistenceSettings.ConnectionString).","Or configure the individual feature directly: feature.ConfigureFeature(new EfCorePersistenceFeatureOptions { ConnectionString = ... }).","Pull the value from configuration/environment and assert it's non-empty at startup before building the host.","If the connection string is environment-specific, ensure appsettings.json/environment variables are loaded in the failing environment."],"exampleFix":"// before\nservices.AddElsa(elsa => elsa.UseEntityFrameworkCore(ef => ef.UseSqlite()));\n// after\nservices.AddElsa(elsa => elsa.UseEntityFrameworkCore(ef => ef.UseSqlite(\"Data Source=elsa.db\")));","handlingStrategy":"validation","validationCode":"var settings = sp.GetService<IOptions<SharedPersistenceSettings>>()?.Value;\nvar cs = featureConnectionString ?? settings?.ConnectionString;\nif (string.IsNullOrWhiteSpace(cs))\n    throw new InvalidOperationException(\n        \"No connection string configured for EF Core persistence. Set the feature options or SharedPersistenceSettings.ConnectionString.\");","typeGuard":"bool HasPersistenceConnectionString(string? featureCs, SharedPersistenceSettings? shared) =>\n    !string.IsNullOrWhiteSpace(featureCs) || !string.IsNullOrWhiteSpace(shared?.ConnectionString);","tryCatchPattern":null,"preventionTips":["Configure connection strings centrally via the combined persistence feature instead of per-feature.","Validate configuration at startup (fail fast in Program.cs) before the host builds.","Keep connection strings in appsettings/environment per environment and assert non-empty in CI."],"tags":["efcore","persistence","configuration","connection-string"],"backgroundTag":"missing-required-config-field","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}