The property '***' is not a String or Byte array. Length can only be configured for String and By...

花明

关注

阅读 53

2023-03-22


The property '*' is not a String or Byte array. Length can only be configured for String and Byte array properties的问题解决

在EntityFramework中执行Migration操作时报错

The property '*' is not a String or Byte array. Length can only be configured for String and Byte array properties

发现时Model类Property设置了不当的Stringlength导致的

比如如下两种情况

不当的设置int的StringLength

[Required] 
//[MaxLength(1)]
public int Private { get; set; }

不当的为bool设置StringLength

[Required]
//[StringLength(50)]
public bool IsActive { get; set; }

解决办法

如上代码所示,把不当设置的StringLength取消就可以正常操作了

精彩评论(0)

0 0 举报