/// <summary> /// SpecifyKind of DateTime fields with DateTimeKind.Utc as a best-practice in web applications /// </summary> /// <param name="builder"></param> public static void NormalizeDateTime(this ModelBuilder builder) { var conversion = new ValueConverter <DateTime, DateTime>( v => v, v => SystemTime.Normalize(v)); var propertyList = builder.Model.GetEntityTypes().SelectMany(t => t.GetProperties()) .Where(property => property.ClrType == typeof(DateTime) || property.ClrType == typeof(DateTime?)) .Where(property => !property.PropertyInfo.GetCustomAttributes <SkipNormalizationAttribute>().Any()); foreach (var property in propertyList) { property.SetValueConverter(conversion); } }