title: How to add columns to database using Entity Framework code-first migration?
body: <p>I have a simple ASP.NET MVC application which uses Entity Framework code-first.</p>
  
  <p>Here is the structure of the project: there are three layers:</p>
  
  <ul>
  <li>Data Layer - contains database context</li>
  <li>Web Layer - contains interfaces(Web pages)</li>
  <li>Model layer - contains Models for EF</li>
  <li>Service Layer - Calles to map data layer and Models</li>
  </ul>
  
  <p>I have added a new property called <code>ImageUrl</code> to the modules model</p>
  
  <pre><code>public class Module:TEntity
  {
          [ScaffoldColumn(false)]
          public string ModuleCode { get; set; }
          public string DisplayName { get; set; }
          public string Description { get; set; }
          [ScaffoldColumn(false)]
          public DateTime CreatedDate { get; set; }
          [ScaffoldColumn(false)]
          public string CreatedUser { get; set; }
          [ScaffoldColumn(false)]
          public string IsActive { get; set; }
          [ScaffoldColumn(false)]
          public string ParentModule { get; set; }
          [ScaffoldColumn(true)]
          public string ImageUrl { get; set; }
  }
  </code></pre>
  
  <p>and my <code>dbContext</code> class as follows:</p>
  
  <pre><code>public DbSet&lt;Module&gt; WebMstModule { get; set; }
  
  public Direct2M3DBContext() : base(new DatabaseFactory().GETDATABASE(SystemType.DIRECT2M3).getConnectionStr()) {  
  }
  
  protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;Model.Direct2M3.Module.Module&gt;().ToTable("WebMstModule");
  }
  </code></pre>
  
  <p>Then I enabled migration using </p>
  
  <pre><code>Enable-Migrations -ContextTypeName Direct2M3DBContext
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>Add-Migration AddImageUrl
  </code></pre>
  
  <p>Add Migration Output</p>
  
  <p><strong>Scaffolding migration 'AddImageUrl'.
  The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration AddImageUrl' again.</strong></p>
  
  <p>at the end</p>
  
  <pre><code>update-database -verbose
  </code></pre>
  
  <p>there is no error, but generated migration file ends up being empty and down method</p>
  
  <pre><code>public partial class AddImageUrl : DbMigration
  {
          public override void Up()
          {
          }
  
          public override void Down()
          {
          }
  }
  </code></pre>
  
  <p>and new column does not get created on the server.</p>
  
  <p>Are there any steps I missed ?</p>
  
  <p>Thanks..</p>