title: Saving a DateTime to a code-first generated database exception
body: <p>I have the following model entity:</p>
  
  <pre><code>public class ScheduledTask
      {
          public virtual int ScheduledTaskId { get; set; }    
          public virtual Incident TemplateIncident { get; set; }
          //Some props are omitted for simplicity    
          [Display(Name = "Next runtime")]
          [Required]
          [DataType(DataType.DateTime)]
          public virtual DateTime NextExecuteAfterDate { get; set; }
      }
  </code></pre>
  
  <p>It is a part of a DataContext as: </p>
  
  <pre><code>public DbSet&lt;ScheduledTask&gt; ScheduledTasks { get; set; }
  </code></pre>
  
  <p>A UI in a solution is an MVC3 site.</p>
  
  <p>Whenever a user is saving a record, a schedulable task is being saved along:</p>
  
  <pre><code>_db.Add(new ScheduledTask
                          {
                              NextExecuteAfterDate = DateTime.MinValue,
                              Schedule = scheduleTypeId,
                              TemplateIncident = incident
                          });
              _db.SaveChanges();
  </code></pre>
  
  <p>As you can see, I am creating an instance of my entity class, assigning a <code>DateTime</code> property a minimum value and adding it to a <code>DbContext</code>. Then I call <code>SaveChanges()</code>.</p>
  
  <p><code>SaveChages()</code> generates an</p>
  
  <pre><code>[SqlException (0x80131904): The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
  The statement has been terminated.]
  </code></pre>
  
  <p>A <code>NextExecuteAfterDate</code> in a database is a Column of a type <code>datetime, not null</code>.</p>
  
  <p>Where does datetime2 come from, and how can I fix the problem and get EF to add a row to a table?</p>