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)
爲什麼會這樣呢?這是什麼?
將它更改爲整數還是存在一切風險?
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