在EF CodeFirst中记录用户更改的历史记录 [英] Logging history of user changes in EF CodeFirst
问题描述
请建议在EF codefirst中实现此方法。
编辑后:
哪一个更好?
1.创建一个表来保存所有表日志
2.为数据库中的每个表创建一个表
覆盖SaveChanges方法
在SaveChanges方法中循环使用ObjectStateManager.GetObjectStateEntries
然后使用ObjectStateEntry CurrentValues.DataRecordInfo.FieldMetadata []。FieldType.Name和entry.CurrentValues来获取名称值对
I want save history of user changes on DB Records. Changes such as edit records (for example value of FirstName field changed from 'n ' to 'x' by user1 in yyyy/dd/mm") , Delete Records and ... .
please suggest a method to implement this in EF codefirst.
After Edit:
And which one is better?
1.Create one table to save all tables log
2.Create a table for each table in database
Override the SaveChanges method.
In your SaveChanges method loop through the entries using ObjectStateManager.GetObjectStateEntries
Then use the ObjectStateEntry CurrentValues.DataRecordInfo.FieldMetadata[].FieldType.Name and the entry.CurrentValues to get the name value pairs
这篇关于在EF CodeFirst中记录用户更改的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!