Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using ASP.Net Membership plus an additional table to store user Information, should I link other tables to aspnet_Users or my own Table?

I'm using ASP.Net membership to secure my site and I have a question about how to store extra user information. By googling and reading other questions I think the 3 accepted approaches to storing additional data

  1. Profile framework - generally regarded as too restricting
  2. Custom Profile provider - a little bigger than I want to attempt at the moment
  3. Using another table with user information - the choice I'm following

I've created a new table in addition to the ASP.Net membership tables named User_Information that has a one-to-one foreign key to aspnet_Users. When I create a new table to store information linked to a user (e.g. comments, votes, etc) should I set the foreign key to point to aspnet_User or my User_information table?

thanks

like image 384
pnewhook Avatar asked Dec 21 '09 04:12

pnewhook


People also ask

Which instance holds the user identity in ASP.NET page?

This instance is of type IPrincipal . IPrincipal is a special interface used to represent different identity types inside ASP.NET. It holds an IIdentity that represents the user identity plus its roles as an array of strings.

What is ConcurrencyStamp?

A stamp that is used to identify the current version of the data. If you change it, so does the stamp. So if two concurrent updates comes in at the same time, they must have the same stamp or one of them should be discarded. Hence the name, ConcurrencyStamp .


2 Answers

It depends on the nature of your queries.

The Membership provider will give you easy access to the user ID column from the aspnet_Users table. It will take an extra query to get the ID from your table.

However, if most of your queries require joining your User_Information table anyway, then it may not really matter.

like image 182
RickNZ Avatar answered Oct 12 '22 23:10

RickNZ


I use the same way as you did. I have a weak-reference without any physical relationship between those two tables. It works perfectly fine for me. To manage dependencies you can wrap the database operations within a transactions for both the tables.

I recommend not to create any foreign key and continue with this design.

like image 29
this. __curious_geek Avatar answered Oct 13 '22 00:10

this. __curious_geek