简体   繁体   中英

What is aspnet_Users and aspnet_Membership? Which one should I use? What is the difference?

I'm using default membership class in my website. But I'm a little confused with the complex database design of the ASPNETDB.

Let's say I want to add details about user like name, surname, address etc... Where should I put them aspnet_Membership table or aspnet_Users table and why? I mean I can see that I should put the details on aspnet_Membership. But then again why there is two of them and the bindings on aspnet_Users...

Or lets say I'm adding a messaging into that which table should I key to, for the user details?

I'm confused and I would be appreciated if you can tell me the use of these two tables.

Here is the diagram for the default ASPNETDB which you should probably have:

在此输入图像描述

Rather than modifying the built in ASP.NET membership schema, you can use ASP.NET profiles to store custom properties about your users. Here's one tutorial on the subject.

You can add the profile tables to your schema using aspnet_regsql.exe (which you're probably already familiar with, given that you have already generated most of the schema). Use the -R p switch to get the profile tables/procs.

If you want to connect your custom table to ASP.NET membership, use UserId as foreign key from aspnet_Users table rather than aspnet_Membership table to your custom table. For reference, please note how aspnet_Profile or even aspnet_Membership is using UserId as foreign key from aspnet_Users table.

Please see the database diagram here: http://msdn.microsoft.com/en-us/library/Aa478948.asp2prvdr0102l(l=en-us).gif

Good luck ...

I would advise not to alter any of the tables provided by the ASP.NET membership schema. To store additional data use the already mentioned ASP.NET profiles option or create a custom one which maybe fits your bill beter.

The reason why there are two tables for storing user data is already answered over here . Good luck which choosing the right solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM