While DbContext.SaveChanges is being executed for an entity (table) which has let's say 7 Foreign Keys,
somehow (by virtue of EF or VS2019 or C# or DBContexrt or "this" or all of them) when you press the "Save Button" all of the data is available for that table, including all of the ID's corresponding to each one of its 7 Foreign Keys.
I'd like to also have available the 1st non-Foreign Key pertaining to each one of the Foreign Keys.
For instance, if I have Country, States and Cities entities with CountryID, StateID and CityID Primary keys and also CountryName, StateName and CityName as the "descriptive" column in each one of these tables then I'd like to modify State by also having an extra-column with the name <CountryName> beside to the CountryID (its FK), StateID (its PK) and StateName columns.
For Cities I'd like to have CountryID (FK) , StateID (FK) and CityID (PK) plus CityName and also have extra CountryName and StateName
So the pseudo algorithm would be "save as normally do and also save the corresponding 1st non-FK column of every FK that each table has
In this way I'd like to preserve the integrity of the <labels> used in each transaction for auditing purposes.
Is clear that any of these column <labels> might be accidentally or deliberately changed in the course of coming days, months or years. So the reference you can make (as it does normally when you execute a query) to a <label> of prior transactions (if changed) then it won't match the real picture of what really happened before the change was made.
Is that possible at all and how? I ask, if anyone might be interested in answering, how to do it with real code because I have no the slightest clue in how to achieve it