0

Possible Duplicate:
Unique key with EF code first

How can I define a unique key by EF code first. this is my model:

public class Users {   
  ...
  public string Username { get; set; }
  ...
}

I want to make Username as a unique key.

Community
  • 1
  • 1
Ghooti Farangi
  • 19,926
  • 15
  • 46
  • 61

1 Answers1

-3

By putting a key attribute

public class Users {   
  ...
  [Key]
  public string Username { get; set; }
  ...
}
taher chhabrawala
  • 4,110
  • 4
  • 35
  • 51