We would like to create a history table for each of our entities.
Is there a way to have entity framework create the history entities/tables automatically, given the existing entities?
For example, the
entity would have a shadow history table called
. Whenever there is an edit or a delete, the old record will be inserted into the history table. The main entity table will always contain the current record.
Since we have several entities, I would rather not have to create a separate history entity and repository for each entity, thus doubling the entities.
We would like to do this for all of our entities in order to track transactional and state temporal changes to the entities.
We use the unit of work and repository patterns.
Assume that the properties of the Entity and the
objects would be the same, although we may want to extend the history object with some datetime properties.
I understand how to <a href="http://jmdority.wordpress.com/2011/...-dbcontext-change-tracking-for-audit-logging/" rel="noreferrer">override
in order to write to history/audit tables</a>.
What I want to avoid doing is having to create duplicate history entities/repositories for every entity that we have.
I am currently exploring doing something in
to create a history entity for each entity but have not found a good example.
Any ideas?
Is there a way to have entity framework create the history entities/tables automatically, given the existing entities?
For example, the
Code:
Customer
Code:
CustomerHistory
Since we have several entities, I would rather not have to create a separate history entity and repository for each entity, thus doubling the entities.
We would like to do this for all of our entities in order to track transactional and state temporal changes to the entities.
We use the unit of work and repository patterns.
Assume that the properties of the Entity and the
Code:
EntityHistory
I understand how to <a href="http://jmdority.wordpress.com/2011/...-dbcontext-change-tracking-for-audit-logging/" rel="noreferrer">override
Code:
DbContext.SaveChanges
What I want to avoid doing is having to create duplicate history entities/repositories for every entity that we have.
I am currently exploring doing something in
Code:
OnModelCreating
Any ideas?