In my current project, we're using Entity Framework, and in this context to store data coming in from a remote system. When I attempt to save objects, I need to reliably tell if an exception is something that can be recovered from or not.
To clarify, by "recovered from" I mean that simply attempting the operation again a bit later would be safe and would potentially succeed. This would include issues with network connectivity, the DB server being restarted or similar situations.
Unrecoverable in this context would be basically anything else, including integrity constraints and internal Entity Framework errors (the database being out of sync with the EF model). It could be argued that some integrity constraints might be recovered from if someone "fixes" the data, but in this case there will be only a single writer.
Is there a reliable way of categorizing an exception coming from Entity Framework into one of these two categories?
I think you'll have to come up with your own list of exceptions that you are willing to test for and handle. The list of exceptions that you could classify as recoverable or not wouldn't likely be the same in any two environments. That said, perhaps you can start here:
Where to find ADO.NET Entity Framework error list?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With