Cascade Update In Entity Framework
I have the following scenario involving 2 classes: public class Parent { [Key] public int Id {get;set;} //.. Other properties here public virtual IList Chil
Solution 1:
I believe entity framework does not have cascade update feature,
but I know hibernate has it.
however you could do something like overwritething method savechanges() in ApplicationDbContext class similar to cascade delete mentioned here
ApplicationDbContext : DbContext
{
publicoverrideintSaveChanges()
{
//sets child in ram memory entity state to modified //if its parent entity state is modified each time you call SaveChanges()
Child.Local.Where(r => Entry(r.Parent).State == EntityState.Modified)
.ToList().ForEach(r => Entry(r).State=EntityState.Modified);
base.SaveChanges();
}
}
I think this is what you are looking for, I have not tested this
Post a Comment for "Cascade Update In Entity Framework"