DataAnnotations & Model in .Net Core
DataAnnotations is in System.ComponentModel.DataAnnotations.
1.using System.ComponentModel.DataAnnotations;
1.1 [Required]
1.2 [RegularExpression(@"^\d+$", ErrorMessage = "Only number")]
public long Id { get; set; }
1.3[Display(Name = "Color head")]
public string displayOtherName { get; set; }
1.4[Key]
[Table("view_name")]
public class EFReservation
{
[Key]
public long keyId { get; set; }
}
2.using System.ComponentModel.DataAnnotations.Schema;
2.1 [Table("TableName")]
public class EFBrandConfig{...}
2.2[NotMapped]
public string notMapped { get; set; }
2.3[Column("my_id")]
public string MyID { get; set; }
2.4 [Column(TypeName = "datetime")]
[Required]
[Display(Name = "Start DateTime")]
[Column(TypeName = "datetime")]
public DateTime? Start { get; set; }
3.using System.ComponentModel;
[DefaultValue(0)]
public int myDefaultValue { get; set; }
评论
发表评论