I have a column as follows:
[Column(TypeName="smalldatetime")]
public DateTime LastUpdatedOn { get; set; }
In the Seed
method I have:
context.Database.ExecuteSqlCommand("Alter Table Members Add Default getdate() for LastUpdatedOn");
and also inserted some sample rows.
The database is created fine, including the default values, but when the sample rows are inserted I get:
"The conversion of a datetime2 data type to a smalldatetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."
Why would the current time be out of range for smalldatetime
? I want to stick to smalldatetime
for the database. How do I do it?
PS: When the database column is the default datetime
type, I also get the same error.