New Angular based web version #1

Closed
thomas.nuyken wants to merge 150 commits from main into ddd
2 changed files with 24 additions and 0 deletions
Showing only changes of commit 4a1f1a5a67 - Show all commits

View File

@@ -45,6 +45,8 @@ public static class DependencyInjectionExtensions
services.AddHttpContextAccessor();
services.AddHostedService<ApplyMigrationsService>();
return services;
}

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
namespace Vegasco.WebApi.Persistence;
public class ApplyMigrationsService : IHostedService
{
private readonly IServiceScopeFactory _scopeFactory;
public ApplyMigrationsService(IServiceScopeFactory scopeFactory)
{
_scopeFactory = scopeFactory;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
using IServiceScope scope = _scopeFactory.CreateScope();
await using var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
await dbContext.Database.MigrateAsync(cancellationToken);
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}