Following the question: How to intercept exceptions when working with the Entity Framework?
Is it possible to get some type of error identifier? For example, Primary Key Violation, Foreign Key Inconsistency, and in my specific case, when it is a single key violation.
Anyway, working with EntityFramework I'm intercepting the thrown exceptions as follows:
try {
...
}
catch (DbUpdateException e) {
TempData["Mensagens"] = "Ocorreu um erro enquanto ...";
}
How to identify the specific EF error type and then be able to handle the message?