Update packages, use explicit type, use Microsoft OpenApi package

This commit is contained in:
2025-06-12 17:43:22 +02:00
parent b3ca1ba703
commit d91b837e44
32 changed files with 138 additions and 230 deletions

View File

@@ -2,18 +2,14 @@
namespace Vegasco.WebApi.Persistence;
public class ApplyMigrationsService : IHostedService
public class ApplyMigrationsService(ILogger<ApplyMigrationsService> logger, IServiceScopeFactory scopeFactory)
: IHostedService
{
private readonly IServiceScopeFactory _scopeFactory;
public ApplyMigrationsService(IServiceScopeFactory scopeFactory)
{
_scopeFactory = scopeFactory;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
using IServiceScope scope = _scopeFactory.CreateScope();
logger.LogInformation("Starting migrations");
using IServiceScope scope = scopeFactory.CreateScope();
await using var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
await dbContext.Database.MigrateAsync(cancellationToken);
}