In the constructor of each of my POCO's I have this:
this.StartTracking();
To ensure that tracking is turned on for every instance of one of my POCO's. I have an Entity A which contains a TrackableCollection of Entity B. When I load my instance of Entity A like such:
using(MyContext ctx = new MyContext())
{
entityA = ctx.EntityA.Include("EntityB").Where(x => x.Id== id).FirstOrDefault();
}
Looking at the ObjectsAddedToCollection property on Entity A, there is 1 object flagged as 'Unchanged'. When I do entityA.EntityB[0].MarkAsDeleted(), the state does not get set to 'Deleted' and moved to the ObjectsRemovedFromCollection collection. It just gets removed altogether. I double checked and the ChangeTrackingEnabled is set to True for both Entity A and Entity B. Is there a reason why this is not working? Because of this I cannot delete child entity and persist the changes to the database.