How to make a property required (for field validation) but Nullable for the DB code migrations?
I do have a DB table with a thousand entries. recently was required to add a required DateTime property.
[Required]
[Display(Name = "Birth", Order = 10)]
public DateTime? Birth { get; set; }
If I set [Required] annotation, the Code first migration will add NOT NULL to the column declaration. However all current entries does not have "Birth" data. and it will be NULL.
the Birth property should be required to the view field validatoin, but it could be nullable into the DB. Is that possible somehow?
I already tried add "?" (nullable) to the property and "virtual" without success.
DateTimecan be decorated with[Required]but omitted from the data model.