我正在查看新的ASP.NET标识类上的接口,以及它首先使用实体框架代码创建的数据库.我正在使用Visual Studio 2013 RC.
乍一看,数据库模式看起来相当正常:
But all the keys are NVARCHAR(128)
出于某种疯狂的原因,AspNetUserSecrets.Id
是一个PK,看起来它可以指向AspNetUsers
表中的多条记录.这是否意味着多个AspNetUsers
必须共享同一密码?
当我看到你被迫实现的接口时,这些都是字符串...
public class User : IUser
{
public string Id { get; set; }
public string UserName { get; set; }
}
public class UserSecret : IUserSecret
{
public string UserName { get; set; }
public string Secret { get; set; }
}
public class UserRole : IUserRole
{
public string UserId { get; set; }
public string RoleId { get; set; }
}
public class UserClaim : IUserClaim
{
public string UserId { get; set; }
public string ClaimType { get; set; }
public string ClaimValue { get; set; }
}
public class UserManagement : IUserManagement
{
public string UserId { get; set; }
public bool DisableSignIn { get; set; }
public DateTime LastSignInTimeUtc { get; set; }
}
public class Tokens : IToken
{
public string Id { get; set; }
public string Value { get; set; }
public DateTime ValidUntilUtc { get; set; }
}
public class UserLogin : IUserLogin
{
public string UserId { get; set; }
public string LoginProvider { get; set; }
public string ProviderKey { get; set; }
}
public class Role : IRole
{
public string Id { get; set; }
public string Name { get; set; }
}
所以我接受了这样一个事实,即我可能必须使用PK和FK关系的字符串来实现这一点.
But I'd really love to know WHY it's built like this...?个
EDIT: Time has passed and there are now articles on how to extend the asp.net identity to use int (or guid) fields:个
http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity个