Entity Framework DbCommandInterceptor vs. SQL panel (LINQPad 5)
If I use an Entity Framework DbContext connection in LINQPad 5, define and register an own DbCommandInterceptor, then the result of the command interceptor does not show up in LINQPad's SQL panel.
The actual interception does happen, and its result can be shown in LINQPad Results panel by hooking onto dbContext.Database.Log.
It seems that the SQL commands get to the SQL panel too soon, i.e. before the command interceptors could intercept them.
It would be great if the SQL commands got to the SQL panel after the command interceptors intercepted them.
The actual interception does happen, and its result can be shown in LINQPad Results panel by hooking onto dbContext.Database.Log.
It seems that the SQL commands get to the SQL panel too soon, i.e. before the command interceptors could intercept them.
It would be great if the SQL commands got to the SQL panel after the command interceptors intercepted them.
Comments
This is my code in LINQPad: And this is my DbContext in a separate dll which is used through LINQPad's "Entity Framework DbContext" connection: Inside the SQL panel I do not see the "-- MyInterceptor" text. Inside the Result window I do see it (thanks to "dbContext.Database.Log += command => command.Dump()").
It does not matter whether MyInterceptor's implementation and registration are being done inside the code in LINQPad or in the separate dll (inside DbConfiguration); the behavior is the same in both cases.
You can tell LINQPad not to write SQL translations by doing this in your setup code:
ExecutionEngine.SqlTranslationsEnabled = false;
Then in your ReaderExecuting method:
Util.SqlOutputWriter.Write (command.CommandText);