EF 6 IsRequired() allowing empty strings

后端 未结 3 2262
无人及你
无人及你 2021-02-12 17:24

In past projects with versions of EF5 and EF4, the IsRequired() fluent API method would thrown a DbEntityValidationException if the property was null or an empty string. In my

3条回答
  •  情书的邮戳
    2021-02-12 17:49

    You may be confusing the StringColumnConfiguration.IsRequired Method and RequiredAttribute.

    .IsRequired() marks that column in the database is NOT NULL. The [Required] annotation however, will raised a validation exception if the property is null, contains an empty string (""), or contains only white-space characters.

提交回复
热议问题