Adding custom properties to the Membership user , what are the options?

One of a frequently asked questions is “how to add a custom columns/properties to the MembershipUser class?”.

Based on my experience , there are many ways to do that :

  1. You can use the user profile services to store those custom properties, article [here].
  2. Create a custom database table with a 1-1 relationship with the membership users table and handle the read/write operations on that custom table using ADO.NET or any other data access technology, article [here]
  3. Create a custom MembershipUser that inherits the MembershipUser class and add the new properties.articles [here] and video.

But which method is the best for you ?

every method has proc/cons , i will list them all in the table below:

Storage method Pros Cons
User’s profile Doesn’t require any additional code, just you need to declare the custom properties in web.config and you can then use the Profile class to read/write or manipulate these values not suitable if you are going to display the user information via an external reporting tool like Reporting services.
Custom database table Very flexible and can be displayed using any external reporting tool. Needs more work to handle the data access code and write some helper classes to manipulate the custom user properties.
Custom MembershipUser and MembershipProvider Cleaner,maintainable and flexible solution.Also integrates with the current Login controls. 
It needs more more effort because it will requires to write custom membershipUser and MembershipProvider …
kick it on

No Comments