public static void Initialize() { Instance = new TestWebApplicationFactory(); Client = Instance.CreateClient(); using (var scope = Instance.Server.Host.Services.CreateScope()) { var scopedServices = scope.ServiceProvider; var db = scopedServices.GetRequiredService <BloggingContext>(); db.Database.EnsureDeleted(); db.Database.Migrate(); } }
public DatabaseFixture() { // ... initialize data in the test database ... TestWebApplicationFactory.Initialize(); }