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