I have a project where I am trying to perform basic auditing on my entites outside of the override SaveChanges method. I don't want to perform auditing there in the case when SaveChanges calls are wrapped in transactions. I don't want to create the audits if for some reason the transaction fails.
I was thinking about moving the auditing to the IDbCommandInterceptor NonQueryExecuted method. The issue with this is that after a Save/Update/ or Delete is executed this method is called 7 or 8 times.
Is there another place I can put the auditing code?
EDIT: I am not writing the audits in SQL so rolling back the transaction will not roll back the audit
You can write code to wrap your auditing code into transaction. There is
IEnlistmentNotification
that you should use in you auditing service.And use: