using Hutopy.Modules.Contents.Data; namespace Hutopy.Modules.Contents; public static class DependencyInjection { public static WebApplicationBuilder AddContentModule( this WebApplicationBuilder builder, Action? configureAction = null) { builder.Services.AddDbContext(configureAction); return builder; } public static async Task UseContentModuleAsync( this IApplicationBuilder app, CancellationToken cancellationToken = default) { IServiceScopeFactory scopeFactory = app.ApplicationServices.GetRequiredService(); using IServiceScope scope = scopeFactory.CreateScope(); await using ContentsDbContext context = scope.ServiceProvider.GetRequiredService(); await context.Database.MigrateAsync(cancellationToken); return app; } }