In the designer I can create the entities correctly: they are linked with a dotted line showing a "*" on both sides.
When I try to delete a relation this way:
Code: Select all
public bool RemoveUserFromGroup(string user, string group)
{
Utente utente = context.Utenti.SingleOrDefault(u => u.UserName == user);
Gruppo gruppo = context.Gruppi.SingleOrDefault(g => g.UserGroup == group);
if (utente == null || gruppo == null) return false;
utente.Gruppi.Remove(gruppo);
context.SubmitChanges();
return true;
}
What am I doing wrong?
Thanks