0
点赞
收藏
分享

微信扫一扫

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

花明 2023-03-22 阅读 51


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 条评论