Giorgi / EntityFramework.Exceptions

Strongly typed exceptions for Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql.
https://giorgi.dev/entity-framework/introducing-entityframework-exceptions/
Other
1.51k stars 71 forks source link

[Idea] Strongly typed concrete exceptions using code generation #78

Closed MaximS closed 1 month ago

MaximS commented 1 month ago

Now the library provides common exceptions like unique constraint or check constraint violations. The idea is to scan a DB for all available constrains, generate specific exception classes for them with names like Unique{constraint_name}Violation using Roslyn code generation and map DBUpdateException to this concrete exceptions. Then the code could become something like:

try
{
  dbContext.SaveChanges();
}
catch UniqueEmailViolation e
{
  ...
}