title: How to make EF-Core use a Guid instead of String for its ID/Primary key
body: <p>When I look at the ASP.NET 3 Identity it uses a <code>string</code> and not a <code>Guid</code> for the unique primary key. </p>
  
  <p>In my <code>Entity Framework</code> <code>code first</code> Users' <code>ApplicationUser</code> class I inherit the Identity class</p>
  
  <pre><code>public class ApplicationUser : IdentityUser
  {
  }
  </code></pre>
  
  <p>which results in when I create my Entity Framework migrations a table <code>aspnetusers</code> getting created with a key type of<code>nvarchar(450)</code> instead of <code>uniqueidentifier</code></p>
  
  <p>When I compare this to <code>ASP.NET Identity 2</code> <code>ENtity Framework</code> project it created an ID field of <code>uniqueidentifier</code> and not <code>nvarchar(450)</code></p>
  
  <p>I would imagine for database performance primary keys and foreign keys of <code>uniqueidentifier</code> would be better than <code>nvarchar(450)</code></p>
  
  <p>Is there a way to use for the unique key <code>Guid</code> instead of <code>string</code> and <code>uniqueidentifier</code> instead of <code>nvarchar(450)</code> with <code>ASP.NET Identity 3</code>?</p>
  
  <p>There is a <a href="https://stackoverflow.com/questions/29460212/how-can-the-identity-getuserid-be-made-to-return-a-guid-instead-of-a-string">previous question</a> how to convert a String to a Guid but I want the database table Id to be a Guid.</p>
  
  <p>I found another <a href="https://stackoverflow.com/questions/32134589/why-did-the-new-asp-net-identity-tables-stop-using-guid-uniqueidentifier-type">question</a> as well for a previous BETA when the length was nvarchar(128). The reason given is that not all databases support Guids and it was changed for flexibility. </p>
  
  <p>Is there must be an easy way to change from string to Guid without rewriting the whole <code>identity 3</code>? </p>
  
  <p><code>nvarchar(450)</code> is really overkill and gives all kinds of warnings when creating SQL Server database constraints. Database admins will definitively not like these warnings.</p>