using System.Text.Json; using FinlyticAssets; using FinlyticAssets.Database; using FinlyticAssets.Models.DataToObject.TradeRepublic; using FinlyticAssets.Services; using FinlyticAssets.Util; using Microsoft.EntityFrameworkCore; var builder = Host.CreateApplicationBuilder(args); builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddHostedService(); builder.Services.AddHostedService(); var host = builder.Build(); using (var scope = host.Services.CreateScope()) { try { var context = scope.ServiceProvider.GetRequiredService(); await context.Database.MigrateAsync(); } catch (Exception ex) { Console.WriteLine($"Critical error during database migration: {ex.Message}"); Console.WriteLine(ex.StackTrace); } } host.Run();