I've used this sample to configure OpendID authentication for Azure AD with the MSAL v2 library. It uses the AzureAdAuthenticationBuilderExtensions class to configure OpenId connect events (code shown below).
I want to access my database (EF Core) within those events to check the tenantId and add some custom user claims. The problem is that the injected database context (services.AddDbContext()) is a scoped service and cannot be called within the Configure method.
public static AuthenticationBuilder AddAzureAd(this AuthenticationBuilder builder)
=> builder.AddAzureAd(_ => …Run Code Online (Sandbox Code Playgroud)