Skip to main content
.NET Framework 4.5.2+

Date and Time Properties in EF Core

The example below illustrates how to implement Date and Time Properties in an EF Core class.

public virtual DateTime DateTimeProperty { get; set; }
public virtual DateTime? DateTimeNullableProperty { get; set; }
public virtual TimeSpan TimeSpanProperty { get; set; }

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
See Also