title: entity framework code first not creating tables using VS 2012
body: <p>I have a MVC4 Web api project under visual studio 2012 for which I would like to create and manage database using EF 6.0.2 code first. Actually, the solution entails four projects, namely, </p>
  
  <ul>
  <li>OnlineShop.Application (User interface)</li>
  <li>OnlineShop.Model dedicated to POCO classes only</li>
  <li>OnlineShop.Test for unit tests and</li>
  <li>OnlineShop.Core having UnitOfWork, GenericRepository and
  DatabaseContext classes</li>
  </ul>
  
  <p>Each of the mentioned projects includes an app.config which holds Same connection as that of web.config.</p>
  
  <p><strong>Problem:</strong> After running the project (in debug mode), the database is created as it's shown on server explorer (in visual studio 2012). But, it has no tables!!!</p>
  
  <p>The database context class is also as the following:</p>
  
  <pre><code> public class DatabaseContext : DbContext
  {
      public DatabaseContext() : base("OnlineShopDb")
      {
          Database.SetInitializer(new MigrateDatabaseToLatestVersion&lt;DatabaseContext, Configuration&gt;());
      }
  
      //public static void InitializeDatabase()
      //{
      //    using (var context = new DatabaseContext())
      //    {
      //        context.Database.CreateIfNotExists();
      //        Database.SetInitializer(new MigrateDatabaseToLatestVersion&lt;DatabaseContext, Configuration&gt;());
      //    }
      //}
  
      public DbSet&lt;Person&gt; Persons { get; set; }
      public DbSet&lt;Customer&gt; Customers { get; set; }
      public DbSet&lt;User&gt; Users { get; set; }
      public DbSet&lt;Audit&gt; Audits { get; set; }
      public DbSet&lt;RoleGroup&gt; RoleGroups { get; set; }
      public DbSet&lt;Role&gt; Roles { get; set; }
      public DbSet&lt;UserInRole&gt; UserInRoles { get; set; }
      public DbSet&lt;Order&gt; Orders { get; set; }
      public DbSet&lt;OrderDetail&gt; OrderDetails { get; set; }
      public DbSet&lt;Product&gt; Products { get; set; }
      public DbSet&lt;ProductCategory&gt; ProductCategories { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
          modelBuilder.Conventions.Remove&lt;OneToManyCascadeDeleteConvention&gt;();
          modelBuilder.Entity&lt;Person&gt;().Map&lt;User&gt;(c =&gt; c.Requires("Discriminator").HasValue("User"));
      }
  }
  </code></pre>
  
  <p>I have surfed the web so much, found lots of articles ans samples regarding EF code first approach but unfortunately couldn't handle this bad problem! </p>
  
  <p>I would appreciate it if anyone could help me on this.</p>