public void SaveTopMenuBinding(int topMenuId, int[] menuCategories) { if (topMenuId != 0 && menuCategories.Length > 0) { foreach (var menuCategoryId in menuCategories) { var dbEntry = new TopMenuBinding { TopMenuId = topMenuId, MenuCategoryId = menuCategoryId }; context.TopMenuBindings.Add(dbEntry); } context.SaveChanges(); } }