Get service from WebApplicationFactory in ASP.NET Core integration tests

You need to create a scope from service provider to get necessary service:

using (var scope = AppFactory.Server.Host.Services.CreateScope())
{
    var context = scope.ServiceProvider.GetRequiredService<MyDatabaseContext>();
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)