From 70ca2da7ae09e80d13f46313841eaa313e10e44b Mon Sep 17 00:00:00 2001 From: HueByte Date: Thu, 19 Feb 2026 04:53:43 +0100 Subject: [PATCH] fix: Update connection string handling to allow for empty configuration --- src/EchoHub.Server/Program.cs | 6 ++++-- src/EchoHub.Server/appsettings.example.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/EchoHub.Server/Program.cs b/src/EchoHub.Server/Program.cs index 2858ea6..0e675c1 100644 --- a/src/EchoHub.Server/Program.cs +++ b/src/EchoHub.Server/Program.cs @@ -39,8 +39,10 @@ while (true) // ── SQLite + EF Core ───────────────────────────────────────────────── var defaultDbPath = Path.Combine(AppContext.BaseDirectory, "echohub.db"); - var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") - ?? $"Data Source={defaultDbPath}"; + var configured = builder.Configuration.GetConnectionString("DefaultConnection"); + var connectionString = string.IsNullOrWhiteSpace(configured) + ? $"Data Source={defaultDbPath}" + : configured; builder.Services.AddDbContext(options => options.UseSqlite(connectionString)); diff --git a/src/EchoHub.Server/appsettings.example.json b/src/EchoHub.Server/appsettings.example.json index 8a86ec8..deb46a5 100644 --- a/src/EchoHub.Server/appsettings.example.json +++ b/src/EchoHub.Server/appsettings.example.json @@ -1,7 +1,7 @@ { "Urls": "http://0.0.0.0:5000", "ConnectionStrings": { - "DefaultConnection": "Data Source=echohub.db" + "DefaultConnection": "" }, "Jwt": { "Secret": "CHANGE_ME_minimum_32_characters_long_secret_key",