ef code first - EF codefirst delete all child objects in a many-many scenario? -
how delete child objects in in many many scenario? example, i'd delete roles belonging user.
i'm using ef code first.
first must select roles , remove user instance roles collection. save
var usersroles = user.roles.tolist(); usersroles.foreach(role => user.roles.remove(role)); context.savechanges(); // add new roles user ps. code may not exact, logic should use acomplish this.
Comments
Post a Comment