3

Today I read about the new features in ASP.NET Identity 2.0 alpha.

http://blogs.msdn.com/b/webdev/archive/2013/12/20/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx

Apparently the possibility to use and int or a guid as the primary key for the AspNetUsers table was added after numerous post/questions on stackoverflow.

I started using ASP.NET Identity when the RTM was announced. Since then I have been using the default string (nvarchar(128)) type for the Id column in the AspNetUsers table.

I want my app to be futureproof. So what I'm wordering is wheather or not I should follow the instructions in these new documents on how to change your Id column to and int or a guid.

What is the most appropriate for an e-commerce site?

What is the most appropriate for a regular site?

When to use what?

Update 1:

Already found one good thing about using an int while testing PrimaryKeysConfigTest WebForms sample app (https://aspnet.codeplex.com/SourceControl/latest Samples->Identity->ChangePK->PrimaryKeysConfigTest). When updating the table AspNetUserRoles manually in SQL Server Object Explorer you don't need to copy paste the long guid-string into the UserId and RoleId columns. You remember them by heart.

Update 2:

https://aspnet.codeplex.com/SourceControl/latest Samples->Identity->Identity-PasswordPolicy->Identity-PasswordPolicy is an MVC application and uses a nvarchar(128) for the Id column in AspNetUsers table. If you're looking to implement the new user account confirmation/forgot password features in ASP.NET Identity 2.0 alpha for an MVC application then this is the sample app you should look at.

tereško
  • 58,060
  • 25
  • 98
  • 150
PussInBoots
  • 11,028
  • 9
  • 52
  • 84
  • 1
    The de facto standard for a primary key is an integer. In my experience using GUIDs just lead to more headache than they are worth. Here's a link to a more thorough exploitation. [link](http://stackoverflow.com/questions/1301165/should-i-design-a-table-with-a-primary-key-of-varchar-or-int/1301536#1301536) – Mike Lorenzana Jan 27 '14 at 15:06
  • If so then maybe the default should be an int for a default MVC 5 web app? I wonder what the MVC / Identity team has to say about this!? – PussInBoots Jan 27 '14 at 15:12
  • 1
    This [post](http://stackoverflow.com/questions/19553424/how-to-change-type-of-id-in-microsoft-aspnet-identity-entityframework-identityus/19577113#19577113) may answer _why_. – Jasen Jan 27 '14 at 18:18

0 Answers0