title: Entity Framework Not Creating Database
body: <p>Been playing around with the Code First feature of Entity Framework 4.1 using an ASP.NET MVC 3 project.</p>
  
  <p>However the database (SQL Server 2008 R2) does not automatically create the table mapping on application startup. Any ideas on how to make it do so?</p>
  
  <p>The project has only one POCO:</p>
  
  <pre><code>namespace RIS.Models
  {
      public class Person
      {
          [Key]
          public virtual string NRIC { get; protected set; }
          public virtual string FirstName { get; protected set; }
          public virtual string MiddleName { get; protected set; }
          public virtual string LastName { get; protected set; }
      }
  }
  </code></pre>
  
  <p>It also has the following database context class:</p>
  
  <pre><code>namespace RIS.Models
  {
      public class RIS_DB : DbContext
      {
          public DbSet&lt;Person&gt; People { get; set; }
      }
  }
  </code></pre>
  
  <p>I've added a SQL connection string to the global web.config file as follows:</p>
  
  <pre><code>&lt;add name="RIS_DB" connectionString="Data Source=URAHARA-PC;Initial Catalog=RIS_DB;
  Integrated Security=SSPI;Pooling=False" providerName="System.Data.SqlClient"/&gt;
  </code></pre>
  
  <p>There is also an explicit instruction to create the database if it does not exist in the Global.asax.cs file:</p>
  
  <pre><code>protected void Application_Start()
  {
      Database.SetInitializer(new CreateDatabaseIfNotExists&lt;RIS_DB&gt;());
  
      AreaRegistration.RegisterAllAreas();
  
      RegisterGlobalFilters(GlobalFilters.Filters);
      RegisterRoutes(RouteTable.Routes);
  }
  </code></pre>