My method should not call ApplyAsync() if the service is not registered. I'm trying to add a conditional null, but I still get a null reference at the moment the method is called. Am I doing something wrong?
private static async Task ApplyMigrationsAsync(CancellationToken token)
{
using var scope = Startup.ServiceProvider.CreateScope();
var migration = scope.ServiceProvider.GetService<M.Migrations.IMigration>();
await migration?.ApplyAsync(token);
}