VOOZH about

URL: https://www.giorgi.dev/portfolio/entityframework-exceptions/

⇱ Entity Framework Exceptions | Giorgi Dalakishvili | Personal Website


Entity Framework Exceptions

Giorgi Dalakishvili
Feb 17, 2020
Star on GitHub

Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, Oracle, SQLite and MySql

What does EntityFramework.Exceptions do?

When using Entity Framework Core for data access all database exceptions are wrapped in DbUpdateException. If you need to find whether the exception was caused by a unique constraint, value being too long or value missing for a required column you need to dig into the concrete DbException subclass instance and check the error code to determine the exact cause.

EntityFramework.Exceptions simplifies this by handling all the database specific details and throwing different exceptions. All you have to do is to configure DbContext by calling UseExceptionProcessor and handle the exception(s) such as UniqueConstraintException, CannotInsertNullException, MaxLengthExceededException, NumericOverflowException, ReferenceConstraintException you need.

dotnet core Entity Framework Core SQL Server PostgreSQL MySQL Oracle SQLite
👁 Avatar
Giorgi Dalakishvili
World-Class Software Engineer

Related