为什么用户信息存储在 ASP.NET 默认成员资格提供程序中的两个不同表中?
有两个表:aspnet_users 和 aspnet_membership。 任何人都可以详细说明为什么他们不使用单个表的原因吗?
There are two tables: aspnet_users and aspnet_membership. Can anyone elaborate on the reasons why they don't use a single table for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
成员资格表保存与 MembershipProvider API 接口相关的信息。 users 表存储用户名和用户 ID,这些信息被许多提供商引用。
aspnetdb 系统非常模块化,每个部分都可以通过各个提供者进行定制。 这些表需要分开,以便每个接口都可以重写、重定向等。
The membership table holds information related to the MembershipProvider API interface. The users table stores usernames and user ids, which are referenced from many providers.
The aspnetdb system is very modular and each piece can be customized through the various providers. The tables need to be separated so each interface can be rewritten, redirected, etc.
老实说,这对我来说也没有多大意义。 似乎 aspnet_Membership 表是为了容纳用户/应用程序级别信息而设置的,但 UserID 是 PK。 很奇怪。 也许在以后的版本中,他们自己设置了这样的情况:每个用户确实有多个应用程序。
Dave 提到还有其他表(例如 aspnet_Profile)保存用户特定信息。 ASP.NET 2.0 人员可能只是试图将不同的字段分组分成更容易理解的块。
我知道这只是一堆猜测。 希望有实际了解的人来指点一下。
Honestly it doesn't make much sense to me either. It seems as though the aspnet_Membership table was set up to house user/Application level information but UserID is a PK. Very strange. Perhaps there were setting themselves up for a situation where you do have multiple applications per user in some later release.
Dave mentions that there are other tables like aspnet_Profile that hold user specific info. It could be that the ASP.NET 2.0 folks were just trying to separate out different groupings of fields into more easily digestible chunks.
I know it's just a bunch of conjecture. Hopefully someone with some actual knowledge will chime in.
我从此 找到了这个解释页:
SqlMembershipProvider 将用户帐户信息存储在两个相关表中:
aspnet_Users - 每个用户帐户都有一条记录,存储基本信息。 UserId 列唯一标识系统中的每个用户,并存储为唯一标识符 (GUID)。
aspnet_Membership - 有一个 UserId 列,将每个记录与 aspnet_Users 中的特定记录联系起来。 aspnet_Membership 表存储与每个用户帐户关联的核心数据:电子邮件、密码、安全问题和答案等。
I found this explination from this page:
The SqlMembershipProvider stores user account information in two related tables:
aspnet_Users - has a record for each user account, storing the bare essentials. The UserId column uniquely identifies each user in the system, and is stored as a uniqueidentifier (a GUID).
aspnet_Membership - has a UserId column that ties each record back to a particular record in aspnet_Users. The aspnet_Membership table stores core data associated with every user account: Email, Password, the security question and answer, and so on.
ASP.NET 中的一些其他提供程序(成员资格提供程序除外)也存储特定于用户的信息。 例如个人资料。
有关此内容的更多信息:
多个附带的 ASP.NET 提供程序在用户名上下文中存储/使用信息。
其中之一是MembershipProvider,它提供身份验证存储和一组服务。
另一个是ProfileProvider,它允许针对每个用户保存特定于用户的数据。
无论您是否选择使用 MembershipProvider,您仍然可以使用 ProfileProvider。
由于 ProfileProvider 必须根据用户名存储数据(即由
Context.User.Identity.Name
属性公开),因此它将继续将用户记录添加到 aspnet_Users 中。希望这能澄清分手的原因。
Some of the other providers in ASP.NET (other than the Membership provider) also store user-specific information. e.g. Profile.
More information about this:
Several of the shipped ASP.NET providers store/use information in the context of a user name.
One of these is MembershipProvider, which provides an authentication store and set of services.
Another is ProfileProvider, which allows user-specific data to be held against each user.
You can still use ProfileProvider regardless of whether or not you have chosen to use MembershipProvider.
Because ProfileProvider must store data against a user name (i.e. as exposed by the
Context.User.Identity.Name
property), it will go ahead and add a user record into aspnet_Users.Hopefully this clarifies the reason for the separation.
aspnet_users
包含您创建的用户(身份验证表单)...注意,当您的身份验证设置为 WINDOWS 时,用户是 WINDOWS 用户,例如 domain\firstname.lastnameaspnet_membership
包含在WebPart
和用户设置等内容中使用的成员资格首选项信息The
aspnet_users
contains the users you create (authentication FORMS) ... NOTE THET when your authentication is set to WINDOWS, the users are WINDOWS users e.g. domain\firstname.lastnameThe
aspnet_membership
contains membership preference information used in stuff likeWebPart
s and user settingsaspnet_users 表包含所有用户的信息:匿名和非匿名。 aspnet_membership 表包含有关注册用户(非匿名)的信息。
The aspnet_users table contains information for all users : anonymous and not anonymous. The aspnet_membership table contains information about register users (no anonymous).