Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF6 - Annotation to allow empty string but not allow null

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; }
like image 745
HockChai Lim Avatar asked Aug 04 '16 14:08

HockChai Lim


1 Answers

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; }
like image 159
HockChai Lim Avatar answered Sep 17 '22 16:09

HockChai Lim