Unable to cast object of type 'System.Decimal' to type 'System.Array'.

数据库有一个字段AppID 类型定义为numeric(38, 0)

实体描述如下

    [Key]
    [Column("APP_ID")]
    [Required(ErrorMessage = "APP_ID不能为空")]
    [MaxLength(38, ErrorMessage = "APP_ID最多不超过38个字符")]

    public Decimal APP_ID { get; set; } = 11111;


结果报错Unable to cast object of type 'System.Decimal' to type 'System.Array'.

原因,Decimal 类型,识别为Int不能设置MaxLength属性

猜你喜欢

转载自blog.csdn.net/ujm097/article/details/79967608