views:

224

answers:

2

i have a database that already has a users table

COLUMNS:
userID - int
loginName - string
First - string
Last - string

i just installed the asp.net membership table. Right now all of my tables are joined into my users table foreign keyed into the "userId" field

How do i integrate asp.net_users table into my schema? here are the ideas i thought of:

  1. Add a membership_id field to my users table and on new inserts, include that new field in my users table. This seems like the cleanest way as i dont need to break any existing relationships.

  2. break all existing relationship and move all of the fields in my user table into the asp.net_users table. This seems like a pain but ultimately will lead to the most simple, normalized solution

any thoughts?

+1  A: 

In my experience, the "ASP.NET membership provider" introduces more complexity than it solves. So I'd go for option 2: a custom user table.

P.S. If anyone has been using the "ASP.NET membership provider" with success, please comment!

Andomar
I have used the "ASP.NET membership provider" with success, but not with the built-in SqlMembershipProvider. I created my own custom membership provider to work with my table schema. I didn't implement all the methods for MembershipProvider, just the ones I needed.
John Allers
I almost always end-up writing my own membership and role providers with the associated custom roles HTTPModule. The provider infrastructure is great, but the built in providers are far to limited. This is easy enough to implement and does not tie me into db structures that almost never meet real business needs. If you want to write your own custom provider that is easy as well... (http://www.smelser.net/blog/post/2008/10/29/Ill-be-your-Provider.aspx)
JoeGeeky
+1  A: 

I regularly use all manner of provider stacks with great success.

I am going to proceed with the respectful observation that your experience with the SqlProvider stack is limited and that the path of least resistance seems to you to be to splice into aspnet_db.

The abstract provider stack provides cleanly separated feature sets that compliment and interact with each other in an intuitive way... if you take the time to understand how it works.

And by extension, while not perfect, the SqlProviders provide a very robust backing store for the extensive personalization and security facilities that underly the asp.net runtime.

The more effort you make to understand the workings of these facilities, focusing less on how to modify (read: break) the existing schema and more on how to envision how your existing data could fit into the existing schema the less effort you will ultimately expend in order to ultimately end up with a robust, easily understandable security and personalization system that you did not have to design, write, test and maintain.

Don't get me wrong, I am not saying not to customize the providers. That is the whole point of an abstract factory pattern. But before you take it upon yourself to splice into a database/schema/critical infrastructural system it would behoove you to better understand it.

And once you get to that point you will start to see how simple life can be if you concentrate on learning how to make systems that have thousands of man hours in dev time and countless users every minute of every day work for you the more actual work you will get done on the things that really interest you and your stakeholders.

So - let me suggest that you import your users into the aspnet_db/sqlprovider stack and leverage the facilities provided.

The userId in aspnet_db is a guid and should remain that way for very many reasons. If you need to retain the original integral user identifier - stash it in the mobile pin field for reference.

Membership is where you want to place information that is relevant to security and identification. User name, password, etc.

Profiles is where you want to place volitile meta like names and site preferences.

Anyway - what I am trying to say is that you need to have a better understanding of the database and the providers before you hack it. Start of by understanding how to use it as provided and your experience will be more fruitful.

Good luck.

Sky Sanders
@code poet - i appreciate your thoughts but you still dont deal with the reality that i have 10 tables already joined into my own users table. I need a migration strategy
ooo
@ooo - post your schema and I will be happy to advise. There may be a sweet spot where the two can organically connect.
Sky Sanders
@code poet - essentially i have the users table above and 10 other tables (i think the details of the those tables are irrelevant to the problem) where those tables all have a user_id column that is a foreign key into my existing users table. i am not sure if any additional information is relevant to the debate
ooo
@ooo - it's not a debate - i am simply trying to help. The reason I want to see the schema is to try and get big picture. It could very well be that a simple modification to a stored procedure in aspnet_db could put you on your way. Where are the existing passwords and you you have means to read them in plain text in order to transparently establish aspnet accounts? Are all the other tables simple children, e.g. no convoluted fk relations that cannot support a cascaded deletion? Are the other tables simple meta? could some normalization simplify the problem? Which tables would be better
Sky Sanders
@ooo - suited as profile data? are there any subtle yet serious issues with the schema that might cause problems? these are the things that can be determined with a simple look at a diagram you can create in SMSS in 3 minutes. That is the only reason I ask.
Sky Sanders
@code poet - what is SMSS? The rest of the data and tables is not profile data at all but transaction data and order history and payment history. The db schema is pretty straight forward. There is an Orders table, a Payment table, Allocations table. There were no other users overlapping fields.
ooo
@ooo - Sql Server Management Studio.
Sky Sanders
@code poet - i will upload a schema shortly to help clarify
ooo