Visual Studio 2019 version 16.3 extends the Performance Profiler with a new ‘Database’ option. This will enable the new Database tool that captures all database activity during your profiling session.
Remark: The database tool works with .NET Core projects using either ADO.NET or Entity Framework Core. It also works on traces collected using dotnet trace which means we can collect data anywhere that .NET Core runs (including Linux!) and analyze that data in Visual Studio.
Let’s try it:
- Open the Performance Profiler in Visual Studio by clicking Debug > Performance Profiler.
- Select the checkbox next to “Database” to enable the tool.
- Click on Start to start the profiling session. Now interact with your application in the ways you’re interested in investigating. When you are done click ‘Stop collection’.
- Now you get a table of all the queries that happened during your profiling session along with a graph that shows when and how many queries happen over time.
- After identifying a query that warrants further investigation, you can go to the related code by right-clicking on a row, and selecting “Go To Source File”!