I'm going to create a new Authorization DLL for our exiting and new applications. We want to add the functionability of Identity 2.0 primary for POCO classes, OAuth and claims. (Claims are really important)
As such, the first thing that comes into mind is the Primary Key being a string. I know this can be changed but also I first researched why is it a string and I found out this SO answer : Why do the ASP.NET Identity interfaces use strings for primary and foreign keys? where they cleary specify that string is 'better' to avoid casting, since claims does use strings.
All our current applications uses Int as Primary Key (Auto increment).
Instead of going blind and change the Identity implementations to use int I researched a bit more and one solution suggested in the same SO answer is to have a string representation of the ID.
Something like :
[Index(IsClustered = false)]
string Id
[Index(IsClustered = true)]
int LogicalId
I'm not sure what's a clustered index but reading it's somehow how the row are arranged in physical disk, so it's about performance so I will go with it as is ok.
My questions are:
MAIN : What's best practice / suggestion for this scenario ?
- a) Having a LogicalId int,
- b) overriding the default implementation of Identity with int
- c) convert all your int to string (as guid)
in case of LogicalId (a) :
What would be the purpose of doing that if we can't ever use the PK as string anyway ? How am I supposed to increment the LogicalId when SaveChanges a new entity on the DB ? EF will do that for me automagically ?
in case of override identity implementation with TKey as int: (b)
User Id on Claims are (i guess) always strings. Would that matter if we use several external providers for our users ? Is it possible to create a concrete implementation of EntityFramework for Int ? Anyone already did ?
Uninstall-Package Indentity.EntityFramework
Install-Package Identity.EntityFrameworkInt
that would be nice :D
convert all data to string (c)
Isn't a pain to work with GUIDs ? Those who work with GUID Does you also have another 'simpler' identifier for public use ? Can't stop imaging customer service :
I cannot find your user on our records, can you please provide your user id?
ouch
Site is not working when I click on one of the 50 {similar product}
- What's the product id ?
lol
We have two products equal, please delete one.
- Sure, give me the product id
cuac