using Microsoft.EntityFrameworkCore; using System.Text.Json.Serialization; namespace HyperBooru; public class HyperBooru { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddControllers().AddJsonOptions(o => { var converter = new JsonStringEnumConverter(); o.JsonSerializerOptions.Converters.Add(converter); }); builder.Services.AddRazorPages(); builder.Services.AddSingleton(); builder.Services.AddScoped(p => new HyperBooruDbContext(p.GetRequiredService())); var app = builder.Build(); using var scope = app.Services.CreateScope(); using var db = scope.ServiceProvider.GetRequiredService(); db.Database.Migrate(); #if DEBUG app.UseSwagger(); app.UseSwaggerUI(); #endif app.MapRazorPages(); app.UseStaticFiles(); app.UseHttpsRedirection(); app.MapControllers(); app.Run(); } }