MiniProfiler for AspNetCore MySql connection

319 Views Asked by At

In .Net framework I use MiniProfiler for MySql connection command logging. In my current AspNetCore solution MiniProfiler doesn't show sql commands as well. What MiniProfiler options I should be using to log it?

2

There are 2 best solutions below

1
On

If you're using Entity Framework Core, you need to:

  1. Install the MiniProfiler.EntityFrameworkCore NuGet package.
  2. In your Startup.cs, call AddEntityFramework():
public void ConfigureServices(IServiceCollection services)
{
    services.AddMiniProfiler()
            .AddEntityFramework();
}

Source: MiniProfiler documentation

0
On

Thanks, It is not for Entity Framework, but solution is using MiniProfiler to profile MySQL Server. And the connection is wrap as following:

public DbConnection GetConnection()
{
    DbConnection connection = new System.Data.SqlClient.SqlConnection("...");
    return new StackExchange.Profiling.Data.ProfiledDbConnection(connection, MiniProfiler.Current);
}

But this does not help, as it does not capture actual SQL command with the parameter list. Please suggest if any additional options need to be configured.