title: "The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value." how can I fix
body: <p>I searched about this problem, there were lots of issues about this but all answers were not useful , It did not solve my problem.  Firstly I can not make any changes on database, I have to keep column definition on database so how can I sort out this issue?</p>
  
  <p>DATABASE DEFINITION:</p>
  
  <pre><code>[DeletedDate] [datetime] NULL,
  </code></pre>
  
  <p>C# CODE REPRESENTATION :</p>
  
  <pre><code>public DateTime? DeletedDate { get; set; }
  </code></pre>
  
  <p>I got an error:</p>
  
  <p>The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
  The statement has been terminated.
     at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)....</p>
  
  <p>I have tried this but nothing works for me</p>
  
  <pre><code>[Column(TypeName = "datetime2")]
   public DateTime? PropertyName { get; set; }
  </code></pre>
  
  <p>EDIT : The problem was about I tried to send 0001/01/01  ... to datetime value to sql. and it had caused problem.</p>
  
  <p>The FLUENT API solved my problem.</p>
  
  <pre><code>entity.Property(e =&gt; e.CreatedDate).HasColumnName("CreatedDate").HasDefaultValueSql("(getdate())");
  entity.Property(e =&gt; e.UpdatedDate).HasColumnName("UpdatedDate").HasDefaultValueSql("(getdate())");
  </code></pre>