Pomelo.entityframeworkcore.mysql: SQL Profiler

Created on 22 Sep 2016  ·  4Comments  ·  Source: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

Can anyone recommend a way that i can see the actual complete sql statement that is sent to mysql with this library? The debug logger is outputting the query wit the parameters, but it shows the actual parameter values as ? like below. I'm trying to debug some issues with date parameters and need to see the exact parameter value that mysql is receiving. Thanks!

Executed DbCommand (3,887ms) [Parameters=[@__utcDate_0='?', @__AddDays_1='?', @__viewModel_LastName_2='?' (Size = 8000), @__viewModel_BirthDate_Date_3='?', @__AddDays_4='?'], CommandType='Text', CommandTimeout='30']

All 4 comments

I know this is a hack, but you can use Wireshark to see what exactly gets sent to the database.

The reason you see parameterized logging in the ? format is because the Database Driver is using Prepared Statements. Prepared Statements escape parameters on the DBMS and prevent SQL Injection. The statement is actually sent to the DBMS with the ? marks, and the parameters are sent separately.

1.1.0-rtm-10002 now includes statement logging when Debug or Info logs are used in .NET MVC

I cann't find the statement logging.

startup.cs Configure method:
loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug();

appsetting.json
"Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug" } }

version:
1.1.1-prerelease-10020

@caleblloyd

Please note that you need to use EnableSensitiveDataLogging() to see actual parameter values when configuring the context.

Was this page helpful?
0 / 5 - 0 ratings