Search code examples
mysqlasp.netsqlmembershipprovidersqlroleprovider

ASP MySQLRoleProvider tie roles to users


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


Solution

  • 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

    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.)

    enter image description here