score:3

Accepted answer

I'm not 100% sure because you don't specify, but I'm guessing that your userGroup.Users property is a navigation property generated by the EDMX model, so the entity collection is already created for you, all you need to do is add your users to the collection.

var userGroups = this.ObjectContext.UserGroups;

 foreach (var userGroup in userGroups )
 {
     var ussers = this.ObjectContext.Users.Where(f => f.UserGroupID == item.ID && f.IsActive == true);

     foreach(var user in ussers)
        userGroup.Users.Add(user);
 }

Related Articles