Update README.md with project details, features, requirements, architecture, and data management for PLib video library manager.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace PLib.Infrastructure.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// Brings the local database up to date before the first window is shown.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// While the schema is still moving we create it from the model. Once the shape settles this
|
||||
/// becomes <c>MigrateAsync</c> plus a checked-in migration history.
|
||||
/// </remarks>
|
||||
public sealed class DatabaseInitializer(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
ILogger<DatabaseInitializer> logger) : IHostedService
|
||||
{
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await using var scope = scopeFactory.CreateAsyncScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<LibraryDbContext>();
|
||||
|
||||
var created = await dbContext.Database.EnsureCreatedAsync(cancellationToken);
|
||||
logger.LogInformation("Library database ready (created: {Created})", created);
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
Reference in New Issue
Block a user