I'm having this thought on my mind for quite some time and i still can not find any answer. My DbContext is handled by an UnitOfWork class. So i have one place where savechanges occur and i am catching all of those nasty exceptions and handling them in one place.
But, as it is widely known, the DbContext can sometimes throw other types of exceptions in another places besides in the SaveChanges() method. For example when materializing the entities. But this can happen in many places and it is sometimes overhead to write try catch blocks on every FirstOrDefault() or ToList() call and catching and re throwing exceptions. Sometimes this exceptions can be of SQL type meaning a connection cannot be open, EntityCommandExecutionException or others.
So i was wondering is there any event that DbContext object fires when an exception occurs, so i can subscribe to that event and handle some logic in these scenarios. :)