2
votes

I have a couple of questions regarding Membership Provider. My textbook got me started but I still need more information.

  1. I am using Linq to Entities, does it make sense to also create LINQ entity relationships with my membership provider DB?

  2. I would like to add additional user attributes other than provided in the membership provider. Can I add them to the aspnet.USER table without any issues?

My users will join the website and will gain privildges as they participate, much like Stack Overflow. I want to keep track of their postings by adding a field to the user table to manage that function.

Thanks in advance!

1
It sounds like you want to store profile information in the user table. Have you looked at the Profile Provider? Here's an example: weblogs.asp.net/jgalloway/archive/2008/01/19/…Jim Schubert

1 Answers

2
votes

There are two ways to associate additional information with user accounts when using the Membership model. The first - which affords the greatest flexibility, but requires the most upfront effort - is to create a custom data store for this information. If you are using the SqlMembershipProvider, this would mean creating an additional database table that had as a primary key the UserId value from the aspnet_Users table and columns for each of the additional user properties. In the online messageboard example, the table might be called forums_UserProfile and have columns like UserId (a primary key and a foreign key back to aspnet_Users.UserId), HomepageUrl, Signature, and IMAddress.

Rather than using custom data stores, the ASP.NET Profile system can be used to store user-specific information. The Profile system allows the page developer to define the properties she wants to associate with each user. Once defined, the developer can programmatically read from and assign values to these properties. The Profile system accesses or writes the property values to a backing store as needed. Like Membership and Roles, the Profile system is based on the provider model, and the particular Profile provider is responsible for serializing and deserializing the property values to some data store. The .NET Framework ships with a SqlProfileProvider class by default, which uses a SQL Server database table (aspnet_Profile) as its backing store.

Examining ASP.NET's Membership, Roles, and Profile - Part 6 By Scott Mitchell

This should get you started. I guess I could answer your questions as follow:

  1. It shouldn't be necessary. Explore the membership API, everything you ever wanted is... probably in there.
  2. Read the article and decide what's best.

Good luck, :).

Sincerely, Maxime