0

I cannot seem get it working. My situation:

  • Microsoft.EntityFrameworkCore 3.1.22 (cannot upgrade)
  • MiniProfiler.EntityFrameworkCore 4.2.22
  • No IServiceProvider (legacy code base, cannot upgrade)

So I'm trying to use it like in a console app:

    MiniProfiler.Configure(MiniProfiler.DefaultOptions).AddEntityFramework();

    using SqlConnection sqlConnection = new(ConnectionString);

    DbContextOptionsBuilder<MyContext> optionsBuilder = new();
    optionsBuilder.UseSqlServer(sqlConnection);

    var profiler = MiniProfiler.StartNew("M");
    var ctx = new MyContext(optionsBuilder.Options);

    using (MiniProfiler.Current.Step("Query"))
    {
        var actual = ctx.Set<PLine>().Take(1).ToArray();
    }

    string profilerText = profiler.RenderPlainText();

The context is OK and the query is working (I can see in in SQL Profiler). My expectation is that profilerText would contain all sql text going to my SQL Server. Instead, all I see is something like this:

VM3 at 2022-03-16 4:40:27 PM
M 0ms
>> Query 3,599.9ms (sql = 456.8ms in 3 cmds)

I also tried to wrap the connection with ProfiledDbConnection with no result. What am I missing?

UserControl
  • 14,766
  • 20
  • 100
  • 187
  • The code base targets .NET 4.8 and we're trying to upgrade EF6 to EF Core. Since we cannot upgrade directly to EF Core 5/6 we must use EF Core 3. – UserControl Mar 16 '22 at 19:39
  • 1
    Have a look here: https://stackoverflow.com/questions/53321634/unable-to-print-query-using-miniprofiler The default RenderPlainText() won't have details rendered from the Steps which is where the profiler would drill down to individual queries. – Steve Py Mar 16 '22 at 21:37

0 Answers0