You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
720 B
23 lines
720 B
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace OpenIddict.Sandbox.Console.Client;
|
|
|
|
public class Worker : IHostedService
|
|
{
|
|
private readonly IServiceProvider _provider;
|
|
|
|
public Worker(IServiceProvider provider)
|
|
=> _provider = provider;
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
await using var scope = _provider.CreateAsyncScope();
|
|
|
|
var context = scope.ServiceProvider.GetRequiredService<DbContext>();
|
|
await context.Database.EnsureCreatedAsync(cancellationToken);
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
}
|
|
|