The scenario is .net core 5 Web API, services.AddDbContext is used in Startup.cs ConfigureServices to add SQL server. The test uses the WebApplicationFactory provided by MVC