my model includes a nullable datetime property.Im using CodeFirst
public DateTime? GoDate { get; set; }
I would like to insert a nullvalue into that field but EF inserts the usual 00/00/0001 date instead of null, which also gives me an error.
im using microsoft sql server 2012.
DateTime? date = null;
var entity = new Model()
{
GoDate = date
};
DataContext.Models.Add(entity);
DataContext.SaveChanges();
give me the error.
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated.
That is because sql server datetime cant have 00/00/0001, which EF automatically generates once it inserts a null datetime into the database.
I want to insert null into the db.

SaveChanges()and post it here.