Search code examples
sqlasp.net-mvcrolesauthorize

Reusing my UserManager tables for Roles manager (membership service)


I am using a UserManager feature with renamed table names (through db context configuration):

        modelBuilder.Entity<User>().ToTable("Users");            
        modelBuilder.Entity<IntUserRole>().ToTable("UserRoles");
        modelBuilder.Entity<IntUserLogin>().ToTable("UserLogins");
        modelBuilder.Entity<IntUserClaim>().ToTable("UserClaims");
        modelBuilder.Entity<IntRole>().ToTable("Roles");

Now, once id like to use [Authorize] attribute with Roles option, id need to launch aspnet_regsql.exe againt my DB to have all the required stored procedures created.

Unfortunately it creates a new set of default named tables (aspne_Roles ...).

Is there a way to make it reusing my tables?


Solution

  • Solved this. Issue was related to wrong configuration. Basically i didnt need any special role management feature, but simply check if user assigned to not to the role.

    To resolve, i changed my configuration to use a simple as possible one:

    <roleManager enabled="true">
    

    Now, my renamed tables used for role management along with my UserManager initialized for my default site context.