Date and Time Properties in EF Core(EF Core 中的日期和时间属性)
The example below illustrates how to implement Date and Time Properties in an EF Core class.
下面的示例说明了如何在EF Core类中实现日期和时间属性。
C#
public virtual DateTime DateTimeProperty { get; set; }
public virtual DateTime? DateTimeNullableProperty { get; set; }
public virtual TimeSpan TimeSpanProperty { get; set; }
public virtual TimeSpan? TimeSpanNullableProperty { get; set; }
public virtual DateOnly DateOnlyProperty { get; set; }
public virtual TimeOnly TimeOnlyProperty { get; set; }
public virtual TimeOnly? TimeOnlyNullableProperty { get; set; }
// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.