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?