I'm trying to use GraphDiff and Entity Framework to update a set of records across multiple tables. Everything works except I need to delete the orphaned record for any of the owned entities that may have been replaced. What am I missing as I expect that this behavior is common and I just need to figure out how to configure the context or graph appropriately. Here is my sample code:
using (EfDataContext ctx = new EfDataContext())
{
try
{
ctx.Database.Log = msg => _sysLogObject.Debug(msg);
ctx.UpdateGraph(assay, map => map
.OwnedCollection(p => p.Imagings, with => with
.OwnedEntity(p => p.ImagingCellType))
.OwnedEntity(p => p.DisplayTemplate)
.OwnedEntity(p => p.ExportTemplate)
.OwnedEntity(p => p.PrintTemplate)
);
ctx.SaveChanges();
success = true;
}
catch (Exception ex)
{
_sysLogObject.Error(ex);
throw;
}
}