Built-in entity auditing!
EF should have some better data change tracking/auditing plumbing...on par with the extensive trace listener class support in ASP.NET. In order to create an audit history of the CRUD actions taking place within my entity model in EF 4.0, I had to write a lot of custom code and override the SavingChanges event and the OnContextCreated method to make it happen. Even now it doesn't properly catch all actions due to certain limitations (such as having DB-set identity fields). Think about how to make auditing data changes simpler and richer for devs!
Marco Monducci commented
Together will all the fabulous features you are introducing I think it could be find room also for a sort of Audit System more business oriented.
We love the new Log & Interceptor hooks but we also need to pull out of the DbContext an easy POCO object based on 3 level of entities like this:
(S)avedChangset (1 instance for every SaveChanges() call with at least Time, User, Application & Session Info)
(E)ntities (a collection of the Entities changed within the same "Saved Changset" with at least TableName & PK)
(A)ttributes (a collection of Attributes changed within the same "Entity", with at least ColumnName, old-data, new-data)
Built with the aim to fill a three tables DB that will be the starting point for dozens of services just like deferred Publisher/Subscriber patterns, logging, tracing, audit and so on....
and we don't love write hundreds of code lines inspecting the DbContext or some other structures, we would prefer to provide some delegates/functions/actions/what-you-prefer at static/constructor/design time to teach DbContext how to create our POCO class structure and, then, at runtime, pull out our well packaged SEA Audit Structur.
Tons of other enhancements could be realized:
like the optional mapping of this new structure with DbContext objects it-self in order to write the Audit Data into DB together with the BusinesData in the same transaction, and so on....
Marco Monducci commented
I think this is strictly related to the issue I raised here: https://entityframework.codeplex.com/workitem/1671
It would be nice to have auditing not dissimilar to https://github.com/loresoft/EntityFramework.Extended/wiki/Audit-Log, but much more flexible and robust. The major issue with it is lack of audit tracking for many-to-many relationships.
Berny Zamora commented
Agreed. This is very helpful when you want to do any kind of logging / auditing.