title: Default value for Required fields in Entity Framework migrations?
body: <p>I've added the <code>[Required]</code> data annotation to one of my models in an <a href="http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-validation-to-the-model" rel="noreferrer">ASP.NET MVC application</a>. After creating a migration, running the <code>Update-Database</code> command results in the following error:</p>
  
  <blockquote>
    <p>Cannot insert the value NULL into column 'Director', table
    'MOVIES_cf7bad808fa94f89afa2e5dae1161e78.dbo.Movies'; column does not
    allow nulls. UPDATE fails. The statement has been terminated.</p>
  </blockquote>
  
  <p>This is due to some records having NULL in their <code>Director</code> columns. How can I automatically change those values to some default (say "John Doe") director?</p>
  
  <p>Here is my model:</p>
  
  <pre><code>  public class Movie
      {
          public int ID { get; set; }
          [Required]
          public string Title { get; set; }
  
          [DataType(DataType.Date)]
          public DateTime ReleaseDate { get; set; }
  
          [Required]
          public string Genre { get; set; }
  
          [Range(1,100)]
          [DataType(DataType.Currency)]
          public decimal Price { get; set; }
  
          [StringLength(5)]
          public string Rating { get; set; }
  
          [Required]     /// &lt;--- NEW
          public string Director { get; set; }
      }
  </code></pre>
  
  <p>and here is my latest migration:</p>
  
  <pre><code>public partial class AddDataAnnotationsMig : DbMigration
  {
      public override void Up()
      {
          AlterColumn("dbo.Movies", "Title", c =&gt; c.String(nullable: false));
          AlterColumn("dbo.Movies", "Genre", c =&gt; c.String(nullable: false));
          AlterColumn("dbo.Movies", "Rating", c =&gt; c.String(maxLength: 5));
          AlterColumn("dbo.Movies", "Director", c =&gt; c.String(nullable: false));
      }
  
      public override void Down()
      {
          AlterColumn("dbo.Movies", "Director", c =&gt; c.String());
          AlterColumn("dbo.Movies", "Rating", c =&gt; c.String());
          AlterColumn("dbo.Movies", "Genre", c =&gt; c.String());
          AlterColumn("dbo.Movies", "Title", c =&gt; c.String());
      }
  }
  </code></pre>