When I look at the ASP.NET 3 Identity it uses a string
and not a Guid
for the unique primary key.
In my Entity Framework
code first
Users' ApplicationUser
class I inherit the Identity class
public class ApplicationUser : IdentityUser
{
}
which results in when I create my Entity Framework migrations a table aspnetusers
getting created with a key type ofnvarchar(450)
instead of uniqueidentifier
When I compare this to ASP.NET Identity 2
ENtity Framework
project it created an ID field of uniqueidentifier
and not nvarchar(450)
I would imagine for database performance primary keys and foreign keys of uniqueidentifier
would be better than nvarchar(450)
Is there a way to use for the unique key Guid
instead of string
and uniqueidentifier
instead of nvarchar(450)
with ASP.NET Identity 3
?
There is a previous question how to convert a String to a Guid but I want the database table Id to be a Guid.
I found another question as well for a previous BETA when the length was nvarchar(128). The reason given is that not all databases support Guids and it was changed for flexibility.
Is there must be an easy way to change from string to Guid without rewriting the whole identity 3
?
nvarchar(450)
is really overkill and gives all kinds of warnings when creating SQL Server database constraints. Database admins will definitively not like these warnings.