title: ASP.Net Identity Database Customise Column Sizes
body: <p>I am currently looking at using ASP.Net Identity with a MySQL Database backend however I have extended this to include with the user an Application Id (much like was available in the old Forms Authentication Membership Database).</p>
  
  <p>This however has presented me with a couple of problems which I hope someone will be able to shed some light on.</p>
  
  <p>1) I need to update the Username and Email indexes on the AspNetUsers table to take the new Application Id column into account as its perfectly valid the same user to be registered against 2 different applications.</p>
  
  <p>2) I would like to customise the sizes of some of the columns within the database as at the moment the Username and Email are being created with a length of 256 which I feel is too large for my requirements.</p>
  
  <p>In attempting to resolve these 2 issues I have tried multiple methods </p>
  
  <ul>
  <li>tagging the fields in the ApplicationUser class with StringLength and Max  Length attributes</li>
  <li>Overriding the OnModelCreating method on the DbContext and adding in the following code</li>
  </ul>
  
  <pre class="lang-cs prettyprint-override"><code>      modelBuilder.Entity&lt;ApplicationUser&gt;().Property(x =&gt;
   x.UserName).HasMaxLength(100);
  </code></pre>
  
  <p>Is there something obvious that I am missing here (for example is what I am attempting even possible).</p>
  
  <p>I have also ruled out MySQL being the issue as I get the same behaviour on SQL 2014 Express.</p>
  
  <p>Any pointers would be much appreciated.</p>
  
  <p>Thanks In Advance</p>
  
  <p>Stuart</p>