ASP.NET Identity update column type for primary ke

2019-07-02 01:24发布

问题:

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.