Entity Framework after save event

entity-framework entity-framework-6

Question

There is aSaveChanges when modifications are saved but before the change tracker is updated, an event that occurs?

I'm using EF 6.

Every time the state of a certain object changes, I have a job to complete.

I have taken control.SaveChanges to configure this. I possessChangeTracker to identify the changes. I start my code when the right entity and the right change are present.

beyond the baseSaveChanges is known as,ChangeTracker no longer indicates that the entity has been updated, thus I must finish my work immediately before saving. But there's a possibility thatSaveChanges will fail, and I ought not to have completed my work.

How do I connect to theChangeTracker before the model and save, but afterChangeTracker is revised?

1
2
5/30/2018 4:09:07 PM

Popular Answer

Can the save changes method be overridden?

//you will use a different dbcontext name than faroutEntities5
public partial class faroutEntities5 : DbContext
{
    public faroutEntities5()
        : base("name=faroutEntities5")
    {
    }

    public override int SaveChanges()
    {
        ChangeTracker.Entries()....

        return base.SaveChanges();
    }

    ...
1
6/7/2017 5:25:07 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow