I have the following Entity Framework query and that query has a DateTime column called by and it is obtained from MySQL, but sometimes it is NULL, and I get an error
The specified conversion is invalid.
I know it is resolved turning my model like
public by? { get; set; }
but I don't want to make it nullable, I would like to know if there is an attribute such as [DefaultValue ()], which indicates that if a null is obtained, it will be converted to a default value, that is, a DateTime.MinValue is inserted so as not to convert the nullable datetime
var Context = new Context();
var docs = Context.Docs.AsNoTracking()
.Where(d => d.froms == "active")
.FirstOrDefault();