I am trying to override SaveChanges() method from DbContext for auditing purpose. When I am overriding it in my application under some partial class MyEntities inheriting DbContext, it works fine without any issue. Also MyEntities class contains few DbSets connecting various DB Tables.
But as soon as Entity Framework is updated, Context.cs file gets updated as it's auto-generated, due to which I am loosing my code.
Is there any way to keep this overidden function in some other class file within /outside same namespace? I tried to create another class file and kept my custom code to override SaveChanges() and perform action on DbSet<>, But this method is not getting called and base SaveChanges() is executed.
I appreciate any suggestions to overcome this. Let me know if anything is required.
Thanks, Pankaj