As I understand it, if a database column is nullable, then the corresponding model variable will be nulllable to.
However, I have a date column that is not nullable but I don't want to specify a value for this column because 1) The database defines a default value for this column that I want to use when creating a new row, and 2) I want to leave this column unchanged
when updating a row.
But there's no way for me to do this. Dates are not nullable. If I leave the date uninitialized, it sets it to some date in the year 1!
The more I use EF, the less I don't like it. I'm willing to try it a little longer but I hope some of the issues I'm seeing can be worked around. Does anyone know if there's a workaround for this one?
JonathanWood
Participant
1138 Points
324 Posts
EF Field is Not Nullable (Cannot Set to DBNull)
Nov 23, 2010 06:07 AM|LINK
As I understand it, if a database column is nullable, then the corresponding model variable will be nulllable to.
However, I have a date column that is not nullable but I don't want to specify a value for this column because 1) The database defines a default value for this column that I want to use when creating a new row, and 2) I want to leave this column unchanged when updating a row.
But there's no way for me to do this. Dates are not nullable. If I leave the date uninitialized, it sets it to some date in the year 1!
The more I use EF, the less I don't like it. I'm willing to try it a little longer but I hope some of the issues I'm seeing can be worked around. Does anyone know if there's a workaround for this one?
Thanks.