namespace Indotalent.Infrastructure.Database.MsSQL; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; public static class MsSQLConfiguration { public static IServiceCollection AddMsSQLContext(this IServiceCollection services, string connectionString) where TContext : DbContext { services.AddDbContext(options => options.UseSqlServer(connectionString, m => m.MigrationsAssembly(typeof(TContext).Assembly.FullName))); return services; } public static void InitializeDatabase(IServiceProvider serviceProvider) where TContext : DbContext { using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); context.Database.EnsureCreated(); } }