I'm trying to test detaching an entity from one context, making modifications to it, creating a new context, attaching it, and having the changes made between sessions persist. I don't seem to be able to get this working appropriately. I've tried calling DetectChanges as well as ApplyCurrentValues w/ no success. Below is what I've got so far. These aren't POCO's and I don't want to treat them as such. I just want to be able to detach an entity, make changes to it, and re-attach it. Thanks!
OCConsumer consumer; using (var ctx1 = new CMSStagingContext()) { consumer = (from c in ctx1.OCConsumers select c).FirstOrDefault(); Console.WriteLine("Retrieved {0} - {1} {2}", consumer.CustomerId, consumer.FirstName, consumer.LastName); ctx1.Detach(consumer); } consumer.BirthDate = "10/22/1981"; using (var ctx2 = new CMSStagingContext()) { ctx2.Attach(consumer); ctx2.ApplyCurrentValues("OCConsumers", consumer); ctx2.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave | System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); }