EF Core event after entities materialized from database

.net entity-framework-core entity-framework-core-2.2

Question

To perform operations before/after entities are written to the database, I can do so before/after .SaveChanges().

How about after entities are read ("materialized") from the database - is there an event, lifecycle hook, callback, or something that I can use?

I'm upgrading a 1.x project to 2.2 and I hope there's something new that allows me to do that.

1
2
5/20/2019 8:19:58 AM

Accepted Answer

From Microsoft documentation, since efcore 2.1 there is now a way to handle some events from ChangeTracker.

State change events

New Tracked And StateChanged events on ChangeTracker can be used to write logic that reacts to entities entering the DbContext or changing their state.

Maybe you can find what you want there.

1
5/20/2019 12:40:28 PM


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