示例:

    public class Phone
    {
        [Key] //主键
        public int Id { get; set; }

        [Required] //不能为空
        [MinLength(2),MaxLength(20)]  //最小长度2,最大长度20
        public string Name { get; set; }

        [StringLength(50)]  //字符串长度为50
        public string Number { get; set; }
        public DateTime CreateDate { get; set; }
        public bool IsValid { get; set; }
        public string Carrieroperator { get; set; }
    }

 

更多的约定配置,可以参考这里:http://www.cnblogs.com/Gyoung/archive/2013/01/17/2864150.html

相关文章:

  • 2021-11-12
  • 2021-07-19
  • 2022-12-23
  • 2019-03-31
  • 2022-12-23
  • 2021-11-07
  • 2021-10-20
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2021-09-25
  • 2021-07-31
  • 2021-08-24
相关资源
相似解决方案