EF Core Performance Analysis Tool - MiniProfiler
- Can monitor the SQL statements executed by EF and the time it takes to execute them. MiniProfiler is a lightweight program for performance analysis targeting .NET, Ruby, Go, and Node.js. It can monitor a page itself, as well as other pages accessed through direct references, Ajax, or Iframes. The monitoring content includes database content, and it can display the SQL used for database access (supports EF, EF CodeFirst, etc.). It also presents this information in a very user-friendly way on the page. The Function of MiniProfiler
- MiniProfiler official website: http://miniprofiler.com/
Usage of MiniProfiler
NuGet Package Installation
Sure, please provide the content you would like translated. //Mvc Install-Package MiniProfiler.AspNetCore.Mvc //Add EF analysis Install-Package MiniProfiler.EntityFrameworkCore Sure, please provide the content you would like translated to English.
Configure MiniProfiler Modify Configuration File
Please provide the content you would like translated to English. // Inject Miniprofiler builder.Services.AddMiniProfiler(options => Please provide the content you would like translated to English. //Access address route root directory; default is: /mini-profiler-resources options.RouteBasePath = "/profiler"; //Data cache time (options.Storage as MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(60); //SQL formatting settings options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(); //Track connection open and close options.TrackConnectionOpenClose = true; //Interface theme color scheme; default light color options.ColorScheme = StackExchange.Profiling.ColorScheme.Dark; //.NET Core 3.0 and above: Analyze MVC filters options.EnableMvcFilterProfiling = true; //Analyze the view options.EnableMvcViewProfiling = true;
// Control access page authorization, default everyone can access
// options.ResultsAuthorize; To control which requests to analyze, it is default that all requests are analyzed. // options.ShouldProfile; //Internal exception handling // options.OnInternalError = e => MyExceptionLogger(e); }).AddEntityFramework(); //Enable This method must be called before app.UseEndpoints. app.UseMiniProfiler(); Sure, please provide the content you would like translated to English.
MVC Project Add the Following Code _ViewImports.cshtml
Please provide the content you would like translated to English.
@using StackExchange.Profiling
@addTagHelper *, MiniProfiler.AspNetCore.Mvc
Sure, please provide the content you would like translated to English.
Add MiniProfiler to the layout file (Views/Shared/_Layout.cshtml)
Sure, please provide the content you would like translated to English.