I would like to use the mysql role provider for aspnet. I have setup a custom table for the users using the attribute userTableName="user". Now the problem is that when I assign users to roles, MYSQLRolesprovider creates an entry in a table "my_aspnet_usersinroles" which and "my_aspnet_users". I would like to specify that the table used to specify roles should be the "user" table. How do I do that? Do I need to write a custom role provider? Is there a setting that I can tweak to make that association? Or am I just using this whole system wrong? Thanks
Asked
Active
Viewed 126 times
2 Answers
0
You need separate tables for users and their roles. Generally, it's three in total, one for the users, one for the roles, and one to tie a user with one or more roles. The usersinroles table allows the one to many relationship so your user can have more than one role. Also, good database design would dictate this as well as the user table should only contain artifacts directly related to the user itself.

Mark Fitzpatrick
- 1,624
- 1
- 11
- 8
-
Thanks @Mark. I have the 3 tables. I just need asp to use my user table ("user", which is a custom table) instead of my_aspnet_users when tying users to roles – Sello Mkantjwa Oct 10 '14 at 20:29
0
specify that the table used to specify roles should be the "user" table.
If you want Membership Provider to use your User table, you need to implement Custom Membership Provider.
Custom Membership Provider requires a lot of work especially if you are new to Membership Provider and Provider Model.
Alternative Approach
- Use FormAuthentication if you do not need Membership Provider's all features.
OR
- create UserId in User tables as PrimaryKey as well as ForeignKey like the following. (One draw back in this approach is you can only use in new application; you cannot implement in existing database.)