为什么ASP.NET Identity 2.0 dbo.AspNetUsers为一个字符串而不是一个int?
问题描述:
ASP.NET身份2.0定义为一个字符串dbo.AspNetUsers:为什么ASP.NET Identity 2.0 dbo.AspNetUsers为一个字符串而不是一个int?
Id = c.String(nullable: false, maxLength: 128)
当可以定义为整数
Id = c.Int(nullable: false, identity: true)
为什么会这样呢?这是什么?
将它更改为整数还是存在一切风险?
答
除了已经链接的答案 - 身份的建立,以便它可以容纳任何类型的存储。我已经看到了Azure Tables和纯文本文件存储的实现。并不是所有这些都可以使用int/guid作为主键,或者甚至可以使用主键。
因此,任何系统的最低公分母 - 一个字符串。但它可以更改为int或Guid或任何存储支持。
[here](http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity)你可以找到如何改变它和[这里] (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=integer%20vs%20string%20primary%20key)约+/-。 – tmg
[为什么ASP.NET Identity 2.0使用GUID /字符串作为用户ID?](http://stackoverflow.com/questions/23891446/why-is-asp-net-identity-2-0-using -a-guid-string-as-user-id) – Shoe