public async Task <IActionResult> Create([Bind("UserDataForeignKey,GroupForeignKey")] UserDataGroup userDataGroup) { if (ModelState.IsValid) { _context.Add(userDataGroup); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GroupForeignKey"] = new SelectList(_context.groups, "GroupId", "GroupId", userDataGroup.GroupForeignKey); ViewData["UserDataForeignKey"] = new SelectList(_context.users, "UserDataId", "UserDataId", userDataGroup.UserDataForeignKey); return(View(userDataGroup)); }