How to assert the number of SQL queries EF Core executes in integration tests?

16 hours ago 1
ARTICLE AD BOX

I want to write integration tests that verify my ASP.NET Core endpoints don't produce N+1 queries. Specifically, I want a test to fail if an endpoint that should execute 1 query suddenly starts executing 10.
I know I can log EF Core queries, but I don't want to parse log output in tests. Is there a clean way to assert the exact number of SQL queries executed during an HTTP request in an integration test?

Read Entire Article