0

If I have class

public class Hotel
{
   public int Id { get; set; }
   public string Name { get; set; }
   ...
}

how can set unique constraint on Name property using code first approach?

Reg Edit
  • 6,719
  • 1
  • 35
  • 46
user1765862
  • 13,635
  • 28
  • 115
  • 220
  • Try this: http://stackoverflow.com/questions/5701608/unique-key-with-ef-code-first See the edit on the answer for EF6.1 solution. – Phil Walton Apr 25 '15 at 17:52
  • For a question specifically on unique constraint (not unique index), see http://stackoverflow.com/q/4413084/1149773 – Douglas Apr 25 '15 at 18:00

0 Answers0