public void Put([FromBody] APT newAPT) { var queryables = context.Apts.Where(x => x.id == newAPT.id).Select(a => new { id = a.id, AlternativeNames = a.AlternativeNames.ToList(), ThreatSignatures = a.ThreatSignatures.ToList(), Name = a.Name, Contents = a.Contents.ToList(), OriginCountries = a.OriginCountries.ToList(), TargetedCountries = a.TargetedCountries.ToList() }); var lists = queryables.AsEnumerable().Select(x => new APT { AlternativeNames = x.AlternativeNames, id = x.id, Name = x.Name, Contents = x.Contents, OriginCountries = x.OriginCountries, ThreatSignatures = x.ThreatSignatures, TargetedCountries = x.TargetedCountries }).ToList(); APT aPT = lists.ElementAt(0); List <Country> targetedCountries = new List <Country>(); List <Country> originCountry = new List <Country>(); foreach (Country c in newAPT.TargetedCountries) { targetedCountries.Add(context.Countries.Find(c.Id)); } foreach (Country c in newAPT.OriginCountries) { originCountry.Add(context.Countries.Find(c.Id)); } context.Entry(aPT).CurrentValues.SetValues(newAPT); context.SaveChanges(); }