title: How to create Unique key for a varchar column for entity framework database?
body: <p>I had watch youtube video tutorial teaching how to create unique key</p>
  
  <p><a href="http://www.youtube.com/watch?v=oqrsfatxTYE&amp;list=PL08903FB7ACA1C2FB&amp;index=9">http://www.youtube.com/watch?v=oqrsfatxTYE&amp;list=PL08903FB7ACA1C2FB&amp;index=9</a></p>
  
  <p>In the video, he has created a unique key for Email(nvarchar) column, I could create it when I create database manually, but when I try create unique key for a database created with entity framework code first, using the next query</p>
  
  <pre><code>ALTER  TABLE Peoples
     ADD CONSTRAINT UQ_MyTable_Email UNIQUE (email)
  </code></pre>
  
  <p>It will generate a error:</p>
  
  <pre><code>Msg 1919, Level 16, State 1, Line 2
  Column 'email' in table 'Peoples' is of a type that is invalid for use as a key column in an index.
  </code></pre>
  
  <p>What is problem? what can I do for create unique key for nvarchar(max) column?</p>