With Code First Data Annotations, if I have already specified the Key attribute for a property will that also make it Required or do I need both?
Basically, if I want to make sure my primary key gets populated, do I need to do this:
[Key]
[Required]
public Guid UserId { get; set; } //internal id
Or will this suffice:
[Key]
public Guid UserId { get; set; } //internal id
No by default Key is required, it’s a first form of normalization and a row without a value for primary key can not be inserted, updated or deleted.