title: Entity Framework Database.SetInitializer simply not working
body: <p>I am having this kind of "mysterious" issue here.
  I am currently using Entity Framework 4.1 Code First approach with my ASP.NET MVC 3 application, it worked great, until yesterday...</p>
  
  <p>Something really bad happened that caused my Database.SetInitializer to stop working.
  Explained:</p>
  
  <p>I have this simple model </p>
  
  <pre><code>public class User
  {
      public int Id { get; set; }
      public int RoleId { get; set; }
  
      [Required]
      [StringLength(50)]
      [DataType(DataType.Text)]
      public string Login { get; set; }
  
      [Required]
      [StringLength(150)]
      [DataType(DataType.EmailAddress)]
      public string Email { get; set; }
  
      [Required]
      [StringLength(32)]
      [DataType(DataType.Password)]
      public string Password { get; set; }
  
      [DataType(DataType.DateTime)]
      public DateTime RegisteredDate { get; set; }
  
      public virtual Role Role { get; set; }
  }
  </code></pre>
  
  <p>And here is my DbContext</p>
  
  <pre><code>public class MyContext : DbContext
  {
      public DbSet&lt;Models.User&gt; Users { get; set; }
  }
  </code></pre>
  
  <p>Also I setup custom initializer (for test)</p>
  
  <pre><code>public class MyInitializer 
              : DropCreateDatabaseIfModelChanges&lt;MyContext&gt;
  {
  }
  </code></pre>
  
  <p>Now I already setup connection string in Web.config (with the name same as MyContext)
  So in Global.asax I am calling this simple code in Application_Start() method</p>
  
  <pre><code>Database.SetInitializer(new MyInitializer());
  </code></pre>
  
  <p>But the problem is that <b>Database.SetInitializer</b> WONT create any database, and even worse, it also not even trying to FILL existing database with tables from context...
  I tried to debug, but it seems like application just jumping over the database initializing code...</p>
  
  <p>I found one solution, is to use this line of code</p>
  
  <pre><code>var ctx = new MyContext();
  ctx.Database.Initialize(true);
  </code></pre>
  
  <p>So here I am just forcing code to create DB anyway...</p>
  
  <p>But the fact Database.SetInitializer wont work is really annoying... it worked great before, I don't know what happened.
  I looked in windows events journal, sql server logs... but nothing is there. Just silence.
  But maybe Im just looking in wrong place? :S</p>
  
  <p>Can anybody tell me what is going on?</p>
  
  <p>P.S I am using Visual Web Developer 2010 + SQL Server Express 2008 R2</p>