I have a class email that looks like this:
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 composite key on Subject, FromandSentOn
This created a problem in which if the object exceeds 128 characters, the check is not performed. So I just put an attribute on it [MaxLength]. But now it cannot be a key column
What should I do? Is there a way to ensure uniqueness without being a key?
source
share