views:

107

answers:

3

Hi everyone,

I'm just starting a new project on ASP.NET MVC and this will be the first project actually using this technology. As I created my new project with Visual Studio 2010, it created to my sql server a bunch of tables with "aspnet_" prefix. Part of them deal with the built-in user accounts and permission support.

Now, I want to keep some specific information about my users. My question is "Is it a good practice changing the structure of this aspnet_ tables, to meet my needs about user account's information?".

And as i suppose the answer is "No." (Why exactly?), I intend to create my own "Users" table. What is a good approach to connect the records from aspnet_Users table and my own custom Users table.

I want the relationship to be 1:1 and the design in the database to be as transparent as possible in my c# code (I'm using linq to sql if it is important). Also, I don't want to replicate the usernames and passwords from the aspnet_ tables to my table and maintain the data.

I'm considering using a view to join them. Is this a good idea?

Thanks in advance!

EDIT: From the answer, I see that I may not be clear enough, what I want. The question is not IF to use the default asp.net provider, but how to adopt it, to my needs.

A: 

Using the membership system in asp.net has its advantages and drawbacks. It's easy to start, because you don't have to worry about validation, user registration, resetting passwords. (Be careful if you plan to modify the table structures, you will have to change them in the views/store procedures generated

However there are drawbacks to using Membership You will have to maintain 2 separated systems, because the Membership API has restrictions, for example, you cannot perform operations inside a transaction with the membership api. (Unless you use TransactionScope i think, but you don't have other choices).

A valid alternative would be to implement your own security validation routines, and using FormsAuthentication. This way you will have total control over your users tables, and remove dependency to the membership API.

Hugo Zapata
The question is not whether to use it or what are the pros and cons
anthares
well, the point is that you should understand the limitations, and that's what me and other users are pointing to you
Hugo Zapata
No, I've already understand the limitation and I've made my choice. That was not my question about. I've very specific questions and what you're saying is totally true (and I agree), but doesn't fit to what I'm asking.
anthares
+1  A: 

If you are choosing to use the Membership API for your site, then this link has information regarding how to add extra information to a user.

I was faced with the same scenario recently and ended up ditching the membership functionality and rolled my own db solution in tandem with the DotNetOpenAuth library.

Alastair Pitts
Thanks for the link, this was exactly what I needed
anthares
+3  A: 

I would create custom membership provider and omit those aspnet_x tables completely. I've seen what happens when one joins these tables and custom ones with nhibernate mappings - pure nightmare.

Arnis L.
Is it using a view a way to avoid this nightmare ?
anthares
@anthares i wouldn't do that. Still feels dirty. :)
Arnis L.