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,150
  • 1
  • 32
  • 42
user1765862
  • 12,589
  • 27
  • 102
  • 186
  • 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