NB: this is a Sql-server Date datatype (Not DateTime, nor DateTime2, which most answers seem to focus on).
How to insert from EF ?
I tried as below, but I am stuck on the .NET side.
TB_MyTable newEntity = new TB_MyTable()
{
col1 = "abc",
col2 = 123
dtCol = DateTime.MinValue,
dateOnlyCol = ??? What goes here, range is '0001-01-01' to '9999-12-31'
};
TB_MyTable inserted = dbCtx.TB_MyTable.Add(newEntity);
int rowsAffected = dbCtx.SaveChanges();
Error on .SaveChanges() is:
{"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."}
Please don't suggest to me to use string on the Right-Hand-Side, it doesn't work :P