Carpool Project: Part #12
October 13, 2010 Leave a comment
I am working though the basic CRUD of EF/Factory and I ran into an issue. I coded
1 public static void DeleteCarpool(Carpool carpool) 2 { 3 using (CarpoolEntities carpoolEntity = new CarpoolEntities()) 4 { 5 var carpoolToDelete = (from cp in carpoolEntity.Carpool_Carpool 6 where cp.CarPoolId == carpool.Id 7 select cp).First(); 8 9 carpoolEntity.DeleteObject(carpoolToDelete); 10 carpoolEntity.SaveChanges(); 11 } 12 } 13
And I got the following error in my unit test:
I then realized I didn’t cascade the changes on the server. I thought EF handled that for me – I guess not. I changed it in SQL Server:
And things ran like a champ….