Unique multiple column in EF6 codefirst
问题 I have a class Email that looks like : public class Email { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Subject { get; set; } public string Body { get; set; } public string From { get; set; } public DateTime SentOn { get; set; } public List<string> To { get; set; } } To ensure uniqueness I made a compound key on Subject , From and SentOn This created the problem that when Subject excess 128 characters, validation fails. So I just put a