I'd like to write some automated tests to measure how much database IO is occurring during particular processes in our application and ensure they never go above a certain threshold.
Outside of EF, you would:
- Open SQL Server Management Studio
- set io statistics on
- ...run your queries
- ... look at the response returned in the Messages window see the statistics.
So I'm wondering if there is some way to get these same measurements as part of the call to DbContext.SaveChanges. I think you could override the SaveChangesAsync and SaveChanges methods to execute the "set io statistics" statement, but doing it that way would result in an extra database hit and also I wouldn't know how to get the statistics back after SaveChangesAsync was complete.
Any thoughts or ideas?