By default, ASP.Net Core Identity uses the type string
for the primary key fields of its built-in entities. For example, the IdentityUser
class has the property Id
as its primary key and its type is string
. (This is mapped to type nvarchar(450)
in SQL Server)
If find this peculiar, especially since by default the values of these keys are actually string representations of Guid
s:
public IdentityUser()
{
Id = Guid.NewGuid().ToString();
SecurityStamp = Guid.NewGuid().ToString();
}
Why have the designers of ASP.Net Core Identity chosen to use type string
for primary keys over, says, type Guid
?