Reputation: 1713
In EF6, is there a annotation that will allow empty string but not allow null?
I've tried [Required]. But this annotation does not allow empty string or null.
[Required]
[MaxLength(80)]
public string ShortDescription { get; set; }
Upvotes: 12
Views: 8295
Reputation: 1713
Looks like I just need to add the (AllowEmptyStrings = true) option to the [Required] annotation.
[Required(AllowEmptyStrings = true)]
[MaxLength(80)]
public string ShortDescription { get; set; }
Upvotes: 17