using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using GameLibrary.Data; using GameLibrary.Repositories; using Microsoft.EntityFrameworkCore; namespace GameLibrary { public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContext(); builder.Services.AddScoped(); builder.Services.AddControllers(); builder.Services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); var app = builder.Build(); app.UseCors("AllowAllOrigins"); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); using (var scope = app.Services.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.Database.EnsureCreated(); } app.Run(); } } }