Is there a way to use a sql profiler for nmemory (an in-memory database)

effort entity-framework

Question

I'm using Entity Framework with Effort, which uses NMemory to run tests without actually having any negative consequences on the database. Does the nmemory database have a method for you to inspect the SQL that is being sent there?

Edit: Regards, @Gert Arnold Investigating DbContext.Database.Log has been my focus. Sadly, my output appears as seen below. Anyone with insight into this? I'm thinking that instead of my sql, I'm getting these null entries.

Opened connection at 4/27/2015 11:08:22 AM -05:00
Started transaction at 4/27/2015 11:08:22 AM -05:00
<null>
-- Executing at 4/27/2015 11:08:23 AM -05:00
-- Completed in 132 ms with result: 1

<null>
-- Executing at 4/27/2015 11:08:23 AM -05:00
-- Completed in 5 ms with result: 1

Committed transaction at 4/27/2015 11:08:23 AM -05:00
Closed connection at 4/27/2015 11:08:23 AM -05:00
Disposed transaction at 4/27/2015 11:08:23 AM -05:00
Opened connection at 4/27/2015 11:08:24 AM -05:00
Started transaction at 4/27/2015 11:08:24 AM -05:00
<null>
-- Executing at 4/27/2015 11:08:24 AM -05:00
-- Completed in 8 ms with result: 1

Committed transaction at 4/27/2015 11:08:24 AM -05:00
Closed connection at 4/27/2015 11:08:24 AM -05:00
Disposed transaction at 4/27/2015 11:08:24 AM -05:00
1
2
4/27/2015 4:13:51 PM

Popular Answer

The commands can be intercepted and recorded.

 // Before command is sent tell EF about the new interceptor
 DbInterception.Add(new MyEFDbInterceptor());


// The interceptor class is called by , see the various interface methods
// just a couple shown here.
public class MyEFDbInterceptor: IDbCommandInterceptor   {
  public void ReaderExecuting(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)    {
     Debug.Writeln(command.CommandText );
     //Debug.Writeln(interceptionContext.Result ); // might be interesting use
}

 public void ReaderExecuted(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
{
  Debug.Writeln(command.CommandText );

}

 }
1
4/27/2015 4:25:02 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow