Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7984915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:25:17+00:00 2026-06-04T11:25:17+00:00

I created: custom custom membership provider custom role provider an user model an role

  • 0

I created:

  • custom custom membership provider
  • custom role provider
  • an user model
  • an role model

It create me the 2 custom tables correctly.
Now I want to create the table between Users and Roles with 2 columns: RoleId, UserId

I should I tweak my models to teach to EF to create this relationship table (UsersInRole)?

User model:

 public class User
{

    [Key]
    public int UserId { get; set; }

    [Required]
    public Int32 CompanyId { get; set; }

    [Required]
    public String UserName { get; set; }

    public String Password { get; set; }

    public String PasswordSalt { get; set; }

    public String Email { get; set; }

    public Boolean IsApproved { get; set; }

    public Boolean IsLockedOut { get; set; }

    public DateTime CreateDate { get; set; }

    public DateTime LastLoginDate { get; set; }

    public DateTime LastPasswordChangedDate { get; set; }

    public DateTime LastLockoutDate { get; set; }

}

Role model:

public class Role
{

    [Key]
    public int RoleId { get; set; }

    [Required]
    [MaxLength(20)]
    public string Name { get; set; }

    public ICollection<string> AssignedUsers { get; set; }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:25:19+00:00Added an answer on June 4, 2026 at 11:25 am

    If you are using code-first EF, then all you should need to do is add a collection of the Users to the Role class and vice-versa. EF takes this two-way link as a signal to create a many-to-many relationship in the underlying data store. To summarize, your classes would be augmented something like this…

    public class User
    {
      ...
    
      List<Role> Roles {get; set;}
    
    }
    
    public class Role
    {
      ...
    
      List<User> Users {get; set;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to Create a new User using Custom Membership Provider but I don't
I created a custom Membership Provider which is now working in production just fine
I have a simple create user wizard and custom membership provider which was taken
We have created a custom membership provider, but we have inherited the Role and
I created a custom membership provider public class MyMembership : MembershipProvider { private IRepository<User>
I created a custom membership and role provider to leverage the authentication and authorization
I need to create a custom membership user and provider for an ASP.NET mvc
I have created a custom CreateUser in Asp.Net Membership. Now what i want is
I am creating custom membership provider for my asp.net application. I have also created
I created STS that does the authentication part. It uses Custom Membership provider. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.