title: How do I create a unique constraint on a field of type string in EF 6?
body: <p>First, I am new to MVC. </p>
  
  <p>I have a Project table which has ProjectID, ProjectNumber, and ProjectDescription fields. The ProjectId is an entityKey of type int, the ProjectNumber needs to be a unique constraint. </p>
  
  <p>How do I do this in entity framework 6.1.3?</p>
  
  <p>in my Project class I have </p>
  
  <pre><code>        public int ProjectID { get; set; }
          [Index(IsUnique = true)]
          [StringLength(200)]
          public string ProjectNumber { get; set; }
          public string ProjectDescription { get; set; }
  </code></pre>
  
  <p>when I generate database from model, the field is not set as unique in the database. </p>
  
  <p>what am I doing wrong?</p>