mvc 类中对应数据库属性

    [StringLength(50)] //可空 对应数据库可空
        [DefaultValue("")]
        [DisplayName("添加人用户名")]
        public string CreateUserName  
        {
            get;
            set;
        }
      //[StringLength(50), Required]  //对应数据库不可空
        //[DefaultValue("")]
        //[DisplayName("添加人姓名")]
        //public string CreateRealName
        //{
        //    get;
        //    set;
        //}
  public int? UnitType  //对应数据库可空
        {
            get;
            set;
        }

  

原文地址:https://www.cnblogs.com/enych/p/9958811.html