简体   繁体   English

Microsoft.AspNet.Identity.EntityFramework-UserIdentity和RoleIdenity ID字段

[英]Microsoft.AspNet.Identity.EntityFramework - UserIdentity and RoleIdenity Id fields

Microsoft.AspNet.Identity.EntityFramework - Objects UserIdentity and RoleIdenity have Id fields of type string, and thus the tables created have data types nvarchar(128). Microsoft.AspNet.Identity.EntityFramework-对象UserIdentity和RoleIdenity具有字符串类型的Id字段,因此创建的表的数据类型为nvarchar(128)。

Shouldn't these objects Id properties be of type System.Guid and the database have datatypes of uniqueidentifier? 这些对象的Id属性是否不应该为System.Guid类型,并且数据库是否具有uniqueidentifier数据类型? Why aren't they? 他们为什么不呢? A GUID is inserted on new User and Role creation. 在新的用户和角色创建中插入了GUID。

It's most likely because the api is storage provider independent so the kept the field types as generic as possible: http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx 这很可能是因为api是与存储提供程序无关的,因此将字段类型保持为尽可能通用: http : //blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity -asp-net-applications.aspx成员系统

"If your application requirements are that this information might be stored in a different storage mechanism such as SharePoint, Azure Table Service, No Sql databases etc. it is now possible to plug in different storage providers." “如果您的应用程序要求此信息可能存储在SharePoint,Azure Table Service,No Sql数据库等不同的存储机制中,则现在可以插入不同的存储提供程序。”

Hao Kung from the ASP.NET team wrote this in a comment on this question on how to change id type to int. ASP.NET团队的Hao Kung在有关如何将id类型更改为int的问题的评论中写道。

So we decided on string keys to avoid having to deal with key serialization issues, the EF default implementation could have used ints as the primary key, GUIDs were just an easy way to generate a random unique string key. 因此,我们决定使用字符串键来避免必须处理键序列化问题,EF默认实现可以将int用作主键,GUID只是生成随机唯一字符串键的简便方法。

字符串用户ID的另一个原因可能是字符串被硬编码到Claims API中,特别是Microsoft.AspNet.Identity.IdentityExtensions.GetUserId ,后者使用System.Security.Claims.Value ,这两个函数都返回字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .NET Standard 2.0中的Microsoft.AspNet.Identity和Microsoft.AspNet.Identity.EntityFramework - Microsoft.AspNet.Identity and Microsoft.AspNet.Identity.EntityFramework in .NET Standard 2.0 错误。 程序集“ Microsoft.AspNet.Identity.EntityFramework”的版本高于引用的程序集“ EntityFramework”的版本 - Error. Assembly 'Microsoft.AspNet.Identity.EntityFramework is higher version than referenced assembly 'EntityFramework 如何告诉Microsoft.AspNet.Identity.EntityFramework使用存储过程 - How can I tell Microsoft.AspNet.Identity.EntityFramework to use stored procedures 不使用Microsoft.AspNet.Identity.EntityFramework的自定义Asp.net MVC 5身份验证 - Custom Asp.net mvc 5 authentication without using Microsoft.AspNet.Identity.EntityFramework 为什么IdentityUser类在Microsoft.AspNet.Identity.EntityFramework命名空间中而不在Core包中? - Why is the IdentityUser class in the Microsoft.AspNet.Identity.EntityFramework namespace and not in the Core package? 'Microsoft.AspNet.Identity.EntityFramework.IdentityUser'未标记为可序列化 - 'Microsoft.AspNet.Identity.EntityFramework.IdentityUser' is not marked as serializable Microsoft.AspNet.Identity.EntityFramework.dll中发生类型为“ System.ArgumentNullException”的异常 - An exception of type 'System.ArgumentNullException' occurred in Microsoft.AspNet.Identity.EntityFramework.dll 类型 Microsoft.AspNet.Identity.PasswordHasher 未定义 - Type Microsoft.AspNet.Identity.PasswordHasher is not defined 模糊参考问题(Microsoft.AspNet.Identity和Microsoft.AspNet.Identity.Core) - Ambiguous reference issue (Microsoft.AspNet.Identity & Microsoft.AspNet.Identity.Core) 如何在 Microsoft.AspNet.Identity 中设置 PhoneNumberTokenProvider 的过期时间 - How to set expiration time of PhoneNumberTokenProvider in Microsoft.AspNet.Identity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM