Automatically update audit information on Entity
- by Nix
I have an entity model that has audit information on every table (50+ tables)
CreateDate
CreateUser
UpdateDate
UpdateUser
Currently we are programatically updating audit information.
Ex:
if(changed){
entity.UpdatedOn = DateTime.Now;
entity.UpdatedBy = Environment.UserName;
context.SaveChanges();
}
But I am looking for a more automated solution. During save changes, if an entity is created/updated I would like to automatically update these fields before sending them to the database for storage.
Any suggestion on how i could do this?
Let me know if any more information is needed.