using Microsoft.Data.Sqlite; using JCL_S.Data; var builder = WebApplication.CreateBuilder(args); // Connection string — SQLite file lives next to the app const string connectionString = "Data Source=JCL_S.db"; // On first run, create the DB from bakery.sql if (!File.Exists("JCL_S.db")) { using var connection = new SqliteConnection(connectionString); connection.Open(); var sql = File.ReadAllText("JCL_S.sql"); using var command = connection.CreateCommand(); command.CommandText = sql; command.ExecuteNonQuery(); Console.WriteLine("✔ Database initialized from JCL_S.sql"); } // Register DbHelper so any Razor Page can inject it builder.Services.AddSingleton(new DbHelper(connectionString)); // Standard Razor Pages setup builder.Services.AddRazorPages(); var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.MapRazorPages(); app.Run();