0

I have a few tests to test the patching functionality. I am using this custom factory https://github.com/aspnet/Docs/blob/master/aspnetcore/test/integration-tests/samples/2.x/IntegrationTestsSample/tests/RazorPagesProject.Tests/CustomWebApplicationFactory.cs

For each test, I want to create new database or at-least clear and seed data again. Because other tests are messing up with data.

1 Answers1

1

You can use

 db.Database.EnsureDeleted();

This ensures that the database for the context does not exist. If it does not exist, no action is taken. If it does exist then the database is deleted.

Peter Schneider
  • 2,879
  • 1
  • 14
  • 17