EntityFrameworkCore.TemporalTables
EntityFrameworkCore.TemporalTables copied to clipboard
Provide read-only access to TemporalEntitiesCache
For auditing purposes, I want to override the DbContext.SaveChanges method to automatically fill user info into a specified column ("UpdatedBy" is usually used in most auditing examples) only for tables that are configured to be temporal. Access to TemporalEntitiesCache is required for two purposes:
- during migration generation, the TemporalEntitiesCache can be read to attach a shadow property to track the user (this saves me from having make all my entity types implement an interface and keep track of which entities use that property in order to sync with temporal support
- during runtime, the TemporalEntitiesCache can be read to determine if the shadow property exists and should be automatically filled
As it is now, I have working code that uses really unsafe reflection to get that property - but everything works as expected. I would like to get rid of the reflection in favor of using a supported method. It looks like there ought to be a few ways to implement that, but I'd think the easiest is just to provide read-only access to the TemporalEntitiesCache.