title: IDbCommandInterceptor never be called
body: <p>I have created an application base on Entity Framework. To separate reading and writing of the database, I am trying to use IDbCommandInterceptor.
  As for my thought, IDbCommandInterceptor will catch the access from EF to database and I could change the connection into another one.
  <strong>Connection is normal,I could get the result from database normally.However, The only embarassed thing is that, my custom DbCommandInterceptor class has even not been called!</strong></p>
  
  <p><strong>My custom Interceptor:</strong></p>
  
  <pre><code>public class EFCommandInterceptor: IDbCommandInterceptor
  {
      public void NonQueryExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext&lt;int&gt; interceptionContext)
      {
          LogInfo("NonQueryExecuted", String.Format(" IsAsync: {0}, Command Text: {1}", interceptionContext.IsAsync, command.CommandText));
      }
  
      public void NonQueryExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext&lt;int&gt; interceptionContext)
      {
          LogInfo("NonQueryExecuting", String.Format(" IsAsync: {0}, Command Text: {1}", interceptionContext.IsAsync,  command.CommandText));
      }
  
      public void ReaderExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext&lt;System.Data.Common.DbDataReader&gt; interceptionContext)
      {
          LogInfo("ReaderExecuted", String.Format(" IsAsync: {0}, Command Text: {1}", interceptionContext.IsAsync, command.CommandText));
      }
  
      public void ReaderExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext&lt;System.Data.Common.DbDataReader&gt; interceptionContext)
      {
          LogInfo("ReaderExecuting", String.Format(" IsAsync: {0}, Command Text: {1}", interceptionContext.IsAsync, command.CommandText));
      }
  
      public void ScalarExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext&lt;object&gt; interceptionContext)
      {
          LogInfo("ScalarExecuted", String.Format(" IsAsync: {0}, Command Text: {1}", interceptionContext.IsAsync, command.CommandText));
      }
  
      public void ScalarExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext&lt;object&gt; interceptionContext)
      {
          LogInfo("ScalarExecuting", String.Format(" IsAsync: {0}, Command Text: {1}", interceptionContext.IsAsync, command.CommandText));
      }
  
      private void LogInfo(string command, string commandText)
      {
          //I add a break point here, but it has never been called;
      }
  }
  </code></pre>
  
  <p><strong>The code to call Interceptor:</strong></p>
  
  <pre><code>var cmdInterceptor = new EFCommandInterceptor();
          System.Data.Entity.Infrastructure.Interception.DbInterception.Add(cmdInterceptor);
          using (var context = new CSMDBContainer())
          {
              var task = context.T_TASK.FirstOrDefault();
              context.SaveChanges();
          }
          System.Data.Entity.Infrastructure.Interception.DbInterception.Remove(cmdInterceptor);
  </code></pre>
  
  <p><strong>Entity Framework section in configuration file:</strong></p>
  
  <pre><code>&lt;entityFramework&gt;
  &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /&gt;
  &lt;providers&gt;
    &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
  &lt;/providers&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any suggestion will be appreciated!</p>