0

ASP.NET Identity 2.0 dbo.AspNetUsers defined as a string:

Id = c.String(nullable: false, maxLength: 128)

When it could be defined as integer:

Id = c.Int(nullable: false, identity: true)

Why is that so? What are the +/- of this?

Does it makes sense to change it to integer or there's a risk of screwing everything?

Tomo
  • 429
  • 1
  • 10
  • 24
  • [here](http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity) you can find how to change it and [here](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=integer%20vs%20string%20primary%20key) about +/- of this. – tmg Sep 07 '16 at 11:52
  • 1
    Possible duplicate of [Why is ASP.NET Identity 2.0 using a GUID/string as user id?](http://stackoverflow.com/questions/23891446/why-is-asp-net-identity-2-0-using-a-guid-string-as-user-id) – jamesSampica Sep 07 '16 at 20:47

2 Answers2

2

In addition to already linked answer - Identity is built so it can accommodate any kind of storage. I've seen Azure Tables and plain text files storage implemented. And not all of these can use int/Guid as a primary key, or even have a primary key at all.

So the lowest common denominator for any system - a string. But it can be changed to an int or Guid or whatever your storage supports.

trailmax
  • 34,305
  • 22
  • 140
  • 234
-1

Don't change it. If you notice, the UserManager class works only where the primary key is of type string.

Bender
  • 1
  • 2