var service = db.Services.Find(orderDto.IdService); var customer = db.Customers.Find(orderDto.CustomerId); var jobDay = db.JobDays.Find(id); order.Sum = orderDto.Sum; order.IsSale = orderDto.IsSale; order.IsCash = orderDto.IsСash; order.Service = service; order.JobDay = jobDay; order.Customer = customer; db.SaveChanges(); The Customer field is null . When you try to set it to null , it remains the same. How to win it?
orderDto.CustomerId- there is no entry in the database with such an ID, respectively, the search results are empty. Try to get a record for the beginning with a known index, and if everythingorderDtoout, sort out what's wrong withorderDto- eastwing