title: Define Entity Framework SetInitializer in web.config
body: <p>Right now, in development I have the following code in the Global.asax.cs file that calls the Entity Framework (v4.1) <strong>SetInitializer</strong> with my <strong>SeedSampleData</strong> method.  This all works perfectly.  </p>
  
  <p>However, I would like to store the SetInitializer "strategy" parameter through a web.config setting so that I can create a deployement script that will automatically set it to <code>new System.Data.Entity.CreateDatabaseIfNotExists&lt;EfDbContext&gt;()</code> instead of my seed method during production deployment.  </p>
  
  <p>The reason for wanting to move this to the web.config is that when I roll out a new deployment to the production server I want to make sure that I don't accidentally leave my seed initializer in the code.</p>
  
  <pre><code>protected void Application_Start()
  {
    //TODO: Figure out how to move the following lines to web.config and have a deployment script modify it when going to production.
  
    //This line is for production
    //System.Data.Entity.Database.SetInitializer(new System.Data.Entity.CreateDatabaseIfNotExists&lt;EfDbContext&gt;());
  
    //This line is for development
    System.Data.Entity.Database.SetInitializer(new Domain.Concrete.SeedSampleData());
  
    //... Remainder of Application_Start calls here...
  }
  </code></pre>