asp.net 默认帐户 ID
asp.net mvc 的默认模板如何存储帐户(AccountController)? 我可以添加唯一编号的 ID,因为到目前为止我发现它使用唯一登录作为 primarz 密钥? 是否有包含这些帐户的表? 我应该寻找哪些课程来与他们合作?
提前致谢。
How does the default template for asp.net mvc store accounts (the AccountController)? Can I add unique numbered ids, since so far I have found out, that it uses unique login as primarz key? Is there a table containing these accounts? And which classes should I look for to work with them?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不使用唯一的登录名作为主键,事实并非如此。 在底层有一个特定于提供者的成员资格标识符,对于 SQL 成员资格提供者来说,它是一个 GUID。
事实上,它甚至比这更复杂,因为您可以让多个应用程序共享成员资格数据库,或者共享用户,或者使用应用程序名称来区分彼此的用户,但调用 ProviderUserKey 每次都会得到正确的结果。
It doesn't use the unique login as the primary key, not really. Under the hood there's a provider specific membership identifier, which in the case of the SQL membership provider is a GUID.
In fact it's even more complicated than that, as you can have multiple applications sharing a membership database, either sharing the users, or using an application name to distinguish their users from each other, but calling ProviderUserKey will get the right result every time.
当第一人注册时,默认的 MVC 应用程序将在 App_Data 目录中生成 ASPNETDB.MDF 文件。 它包含“标准”ASP.NET SQL 成员资格架构,它与各种 MembershipProvider 类相关联。
我还没有真正使用过 SQL 成员身份的内容,但我想您可以扩展架构和类以适合自己。
为什么需要一个唯一的 ID 而不是使用默认的 ID?
The default MVC app will generate an ASPNETDB.MDF file in the App_Data directory when the first person registers. This contains the "standard" ASP.NET SQL membership schema, which ties in with the various MembershipProvider classes.
I've not really worked with the SQL membership stuff, but I imagine you could extend the schema and the classes to suit yourself.
Why do you need a unique id rather than using the default?