Pho3nix
The Legend
Hi all,
Need some assistance. Code is 90% done and really don't want to re-do everything in Linq to Sql
Keep getting the error below :
Code in the repository looks like this :
DB is set up with a one to many relationship (Primary Service -> Secondary Service). All fields are not nullable so I'm very confused. Any help would be appreciated.
Need some assistance. Code is 90% done and really don't want to re-do everything in Linq to Sql
Keep getting the error below :
Code:
System.Data.UpdateException was caught
Message: Entities in 'SecondaryServices' participate in the 'SecondaryService_PrimaryService' relationship. 0 related 'PrimaryService' were found. 1 'PrimaryService' is expected.
Code in the repository looks like this :
Code:
service.PrimaryService = dataContext.PrimaryServices.FirstOrDefault(s => s.Id == service.PrimaryService.Id);
service.SecondaryService = dataContext.SecondaryServices.FirstOrDefault(s => s.Id == service.SecondaryService.Id);
service.PracticeDiscipline = dataContext.PracticeDisciplines.FirstOrDefault(s => s.Id == service.PracticeDiscipline.Id);
dataContext.AddToServiceRequests(serviceRequest);
dataContext.SaveChanges();
DB is set up with a one to many relationship (Primary Service -> Secondary Service). All fields are not nullable so I'm very confused. Any help would be appreciated.