【发布时间】:2020-04-17 05:16:09
【问题描述】:
默认情况下,ASP.Net Core Identity 使用 string 类型作为其内置实体的主键字段。例如,IdentityUser 类将属性Id 作为其主键,其类型为string。 (这在 SQL Server 中映射到类型 nvarchar(450))
如果发现这很奇怪,特别是因为默认情况下这些键的值实际上是 Guids 的字符串表示:
public IdentityUser()
{
Id = Guid.NewGuid().ToString();
SecurityStamp = Guid.NewGuid().ToString();
}
为什么 ASP.Net Core Identity 的设计者选择使用 string 类型作为主键而不是类型 Guid?
【问题讨论】:
标签: asp.net-core asp.net-core-identity