Wednesday, April 24, 2019

Track Entity Issues



we had a good debugging exercise for Track Entity Changes

Issue we had with below code, it marks all child or reference tables
 db.TimeCards.Update(tc);                                             
 db.Entry(tc).State = EntityState.Modified;
 await db.SaveChangesAsync();

because updated because of the line  db.Entry(tc).State = EntityState.Modified;


Solution we temporary applied to fix the issue 

we mark each entity which is not required to be updated as UNCHANGED
 db.Entry(ET.User).State = EntityState.Unchanged;



there are lot of solutions out there , however we are dealing with very large datasets and we had performance issue. above solution worked for our scenarios


No comments:

Post a Comment