Selection in table many to many MVC 5

-1

Hello people, I am working on mvc 5 model first and I have 3 tables. -Roles -Roles Permissions -Permissions when creating the mapping of the database EF does not create the intermediate table (RolesPermisos) as it could make a selection of the table "RolesPermisos" where the role = X in linq. I've tried this but it does not work for me

 var consulta = db.Roles.Include("Permisos").Where(x => x.IdRol == 24).Single();//me esta trayendo todos los rolesPermisos
    
asked by alder hernandez 10.11.2017 в 15:23
source

1 answer

0

Try to change it to see if it works for you:

var consulta = db.Roles.Where(x => x.IdRol == 24).Include("Permisos").FirstOrDefault();
    
answered by 12.11.2017 в 00:43