title: Database.SetInitializer to null not working Entity Framework 4.3.1 Code First
body: <p>I have a context class that inherits from an abstract base <code>AuditableDbContext : DbContext</code>. The <code>AuditableDbContext</code> takes two parameters, one for the auditor and one for the context to audit into. </p>
  
  <p>In the inherited class, I have a default parameterless constructor that calls the other constructors with null parameters and then in the final constructor I call <code>Database.SetInitializer&lt;MyDbContext&gt;(null)</code> after calling the base constructor.</p>
  
  <p>The problem is that even when I do this, I still get the db migration calls on the database server when the application starts.</p>
  
  <pre><code>public abstract class AuditableContext : DbContext
  {
    public AuditableContext(IAuditor auditor, DbContext auditContext)
    {
      // params can be null resulting in no auditing
      // initialization stuff here...
    }
  }
  
  public class MyDbContext : AuditableContext
  {
    // DbSets here...
  
    public MyDbContext() : this(null, null) {}
  
    public MyDbContext(IAuditor auditor) : this(auditor, null) {}
  
    public MyDbContext(IAuditor auditor, DbContext auditContext) 
    : base(auditor, auditContext)
    {
      Database.SetInitializer&lt;MyDbContext&gt;(null);
    }
  }
  </code></pre>
  
  <p>The queries I see on the database are the two common migration queries...</p>
  
  <pre><code>SELECT [GroupBy1].[A1] AS [C1]
  FROM ( SELECT COUNT(1) AS [A1]
  FROM [dbo].[__MigrationHistory] AS [Extent1]
  )  AS [GroupBy1]
  
  SELECT TOP (1) 
  [Extent1].[Id] AS [Id], 
  [Extent1].[ModelHash] AS [ModelHash]
  FROM [dbo].[EdmMetadata] AS [Extent1]
  ORDER BY [Extent1].[Id] DESC
  </code></pre>
  
  <p>Any ideas on how to stop Entity Framework from making these queries?    </p>