title: How to fix The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value
body: <p>I am trying to insert data from another database and this code was working until today. Now it doesn't anymore.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>var itemMember = Db.Members.FirstOrDefault(p =&gt; p.Id == CurrentMember.Id);
  var itemSelectedName = Db.Topics.FirstOrDefault(p =&gt; p.Id == TopicId);
  var itemMap = Db.Reeves.FirstOrDefault(p=&gt; p.Member.Id == CurrentMember.Id);
  var itemReeve = Db.Reeves.FirstOrDefault(p =&gt; p.Member.Id == CurrentMember.Id);
  var item = new Problem
        {
            Name = input.Name,
            Text = input.Info,
            Topic = itemSelectedName,
            WhoIs = itemMember,
            Province = itemMap.Province,
            District = itemMap.District,
            Town = itemMap.Town,
            Reeve=itemReeve,
            Created=DateTime.Now,
            Solved = false,
            Read=false
        };
  
  Db.Problems.Add(item);
  Db.SaveChanges();
  </code></pre>
  
  <p>There is nothing null in the code and it throws an error:</p>
  
  <blockquote>
    <p>The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.</p>
  </blockquote>
  
  <p>What should I do ?</p>
  
  <p>Also this error shows up now:</p>
  
  <blockquote>
    <p>System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while saving entities that do not expose foreign key properties for their relationships. The EntityEntries property will return null because a single entity cannot be identified as the source of the exception. Handling of exceptions while saving can be made easier by exposing foreign key properties in your entity types.</p>
  </blockquote>
  
  <p>but as I said it was working till today :/</p>
  
  <p>Here is view model:</p>
  
  <pre><code>[Display(Name = "Başlık"), Required, StringLength(50)]
  public string Name { get; set; }
  
  [Display(Name = "Bilgi")]
  [UIHint("TinyMCE")]
  public string Info { get; set; }
  
  [Required(ErrorMessage = "Gerekli Alan")]
  [Display(Name = "Konu")]
  [UIHint("DropDownList")]
  [AdditionalMetadata("DataController", "Problem")]
  [AdditionalMetadata("DataAction", "ProblemDrop")]
  public int? TopicId { get; set; }
  </code></pre>
  
  <p>Here is model </p>
  
  <pre><code>public class Problem
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string Text { get; set; }
      public short Sira { get; set; }
      public DateTime Created { get; set; }
      public virtual Topic Topic { get; set; }
      public virtual Member WhoIs { get; set; }
      public virtual Province Province { get; set; }
      public virtual Town Town { get; set; }
      public virtual District District { get; set; }
      public virtual Reeve Reeve { get; set; }
      public Boolean Solved { get; set; }
      public DateTime SolvedDate { get; set; }
      public virtual Member WhoSolved { get; set; }
      public Boolean Read { get; set; }
  }
  </code></pre>
  
  <p>Solved: Date is null could it be the problem ? </p>