Finished Settings page

This commit is contained in:
2025-11-12 17:06:14 +01:00
parent a608f98497
commit e0bf95060a
38 changed files with 675 additions and 34 deletions

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using WorkTime.Models;
namespace WorkTime.Database;
internal sealed class DatabaseContext(DbContextOptions<DatabaseContext> options) : DbContext(options) {
public DbSet<TimeEntry> Entries { get; set; }
}
internal sealed class DbMigrationService(IServiceProvider provider) : IHostedService {
public async Task StartAsync(CancellationToken cancellationToken) {
await using var scope = provider.CreateAsyncScope();
var context = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
await context.Database.MigrateAsync(cancellationToken);
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}