I have implemented a DbCommandInterceptor so that I can log the queries which EF is generating.
I have added the interceptor to my EF Context within the OnConfiguring method as follows
optionsBuilder
.UseSqlServer(dbConnectionString)
.AddInterceptors(new DBContextInterceptorLogging(logger));
The interceptor works, in as much as I can see any SELECT sql query which is generated. However, I do not see any UPDATE, INSERT or DELETE queries being logged.
My DBContextInterceptorLogging class is starting a StopWatch in the overridden ScalarExecuting, NonQueryExecuting, ReaderExecuting, NonQueryExecutingAsync methods, and within the ScalarExecuted, NonQueryExecuted, ReaderExecuted, NonQueryExecutedAsync methods the StopWatch is stopped, and the DbCommand.CommandText is written out to the ILogger<>.
I have also overridden the CommandCreated, CommandFailed and CommandFailedAsync methods.
However, I never see a SQL INSERT/UPDATE/DELETE in my logger output.
If there some flag or filter I have inadvertently set?