StringLength vs MaxLength attributes ASP.NET MVC with Entity Framework EF Code First

前端 未结 8 1658
情歌与酒
情歌与酒 2020-12-04 07:47

What is the difference in behavior of [MaxLength] and [StringLength] attributes?

As far as I can tell (with the exception that [MaxLe

8条回答
  •  不思量自难忘°
    2020-12-04 07:52

    I have resolved it by adding below line in my context:

    modelBuilder.Entity().Property(e => e.YourColumn).HasMaxLength(4000);
    

    Somehow, [MaxLength] didn't work for me.

提交回复
热议问题