The mini profiler does not show any statistics on sql queries
I do setup according to the documentation and the example of the application: https://miniprofiler.com/dotnet/HowTo/ProfileEFCore https://github.com/MiniProfiler/dotnet/blob/main/samples/Samples.AspNetCore3/Startup.cs
here is my Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<MyDbContext>(options => options.UseNpgsql ("connstring..."));
services.AddMiniProfiler()
.AddEntityFramework();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseMiniProfiler();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
...
});
}
and an example of calling an sql query
await using (var context = scope.ServiceProvider.GetRequiredService<MyDbContext>())
{
var myDatas = context.Datas.AsNoTracking()
.Where(x => x.StartTime > now );
foreach (var myData in myDatas)
{
...
}
after executing this request I check the pages with the mini profiler statistics:
https://localhost:port/mini-profiler-resources/results-index
https://localhost:port/mini-profiler-resources/results?id=GUID
and see only this:
| | duration (ms)| with children (ms) | from start (ms)
| https://localhost:port/logins/| 231.9 | 236.5 | +0.0
| MiniProfiler Init | 4.5 | 4.6 | +0.0
| Get Profiler IDs | 0.1 | 0.1 | +4.5
What did I miss ? Why can't I see statistics on SQL queries ?
Figured it out. It was necessary to wrap calls to the database by referring to the mini profiler.
sample code from this article: https://dotnetthoughts.net/using-miniprofiler-in-aspnetcore-webapi/