protected IntegrationTestBase(string baseUrl, ITestOutputHelper output) { BaseUrl = baseUrl; Output = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.TestOutput(output, LogEventLevel.Verbose) .CreateLogger() .ForContext <IntegrationTestBase <TModel, TInsUpdModel> >();; var hostBuilder = new HostBuilder() .ConfigureWebHost(webHost => { // Add TestServer webHost.UseTestServer(); webHost.UseStartup <Startup>(); }); Host = hostBuilder.StartAsync().Result; // Create a new scope using (var scope = Host.Services.CreateScope()) { //Do the migration asynchronously lock (_locker) { DemoDataHelper.Populate(scope.ServiceProvider).Wait(); } } AnonClient = Host.GetTestClient(); Client = Host.GetTestClient(); }