I am using entity framework and membership in my asp.net application.
In one of the pages I need to show all the users and ther roles by joing "aspnet_Membership", "aspnet_Users", "aspnet_Roles" and "aspnet_UsersInRoles" tables.
But whenever i try to add all these tables in the .edmx the "aspnet_UsersInRoles" entity is not getting created instead the "aspnet_Users" and "aspnet_Roles" are getting associated with a Many to Many association. And i can't refrence the "aspnet_UsersInRoles" table, its throwing an compilation error.
Please help me to get the user roles, this is my link query
var users = (from membership in IAutoEntity.aspnet_Membership
from user in IAutoEntity.aspnet_Users
from role in IAutoEntity.aspnet_Roles
where membership.IsApproved == true & membership.UserId == user.UserId
select new { user.UserName, membership.Email, user.aspnet_Roles.TargetRoleName, membership.CreateDate, user.LastActivityDate, membership.IsApproved }).ToList();
UsersInRolesis actually a many-to-many association table - so what's the issue if EF model it as such. You should able to navigate to user's roles (and vice-verse) using navigation property for the association. - VinayC