A library that provides strongly typed exceptions for handling database errors in Entity Framework Core and ADO.NET.
EntityFramework.Exceptions is a .NET library that provides strongly typed exceptions for database errors when using Entity Framework Core or ADO.NET. It solves the problem of having to parse generic DbUpdateException or DbException objects to determine the exact cause of a database failure, such as unique constraint violations or null insertions. By converting database-specific error codes into meaningful exception types, it simplifies error handling and improves code clarity.
.NET developers using Entity Framework Core or ADO.NET for data access who need robust and maintainable error handling for database operations. It is particularly useful for teams building applications with complex data integrity rules across multiple database providers.
Developers choose EntityFramework.Exceptions because it eliminates the boilerplate code required to interpret database error codes, reduces bugs from mishandled errors, and provides a consistent exception model across SQL Server, PostgreSQL, SQLite, Oracle, and MySQL. Its standalone DbExceptionClassifier also offers the same benefits for pure ADO.NET scenarios without EF Core dependencies.
Strongly typed exceptions for Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works with SQL Server, PostgreSQL, SQLite, Oracle, and MySQL, providing consistent error handling across different database systems, as evidenced by the separate NuGet packages listed in the README.
Converts generic DbUpdateException into specific types like UniqueConstraintException, eliminating the need to parse low-level error codes and making code more maintainable, as described in the 'What does EntityFramework.Exceptions do?' section.
Can be integrated with DbContext pooling for performance, as shown in the README under 'Usage with DbContext pooling', allowing seamless use in scalable applications.
Includes DbExceptionClassifier packages for use without EF Core, extending utility to pure ADO.NET scenarios, as detailed in the standalone classifier section of the README.
ConstraintName and ConstraintProperties are not populated for SQLite or indexes defined outside the EF Core model, limiting debugging and handling capabilities, as warned in the README's cautionary notes.
Requires separate NuGet installations for each database provider (e.g., EntityFrameworkCore.Exceptions.SqlServer), adding complexity to dependency management and updates.
Only handles predefined database errors like unique constraints or null inserts; custom constraints or database-specific errors beyond the listed exceptions may not be captured, relying on the library's limited set.