![]() |
VOOZH | about |
dotnet add package EntityFrameworkCore.Exceptions.SqlServer --version 8.0.0.2
NuGet\Install-Package EntityFrameworkCore.Exceptions.SqlServer -Version 8.0.0.2
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="8.0.0.2" />
<PackageVersion Include="EntityFrameworkCore.Exceptions.SqlServer" Version="8.0.0.2" />Directory.Packages.props
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" />Project file
paket add EntityFrameworkCore.Exceptions.SqlServer --version 8.0.0.2
#r "nuget: EntityFrameworkCore.Exceptions.SqlServer, 8.0.0.2"
#:package EntityFrameworkCore.Exceptions.SqlServer@8.0.0.2
#addin nuget:?package=EntityFrameworkCore.Exceptions.SqlServer&version=8.0.0.2Install as a Cake Addin
#tool nuget:?package=EntityFrameworkCore.Exceptions.SqlServer&version=8.0.0.2Install as a Cake Tool
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
👁 Target
👁 AppVeyor
👁 AppVeyor
👁 Coverage Status
👁 Ko-Fi
👁 Maintainability Rating
👁 Vulnerabilities
👁 Bugs
👁 Code Smells
👁 Duplicated Lines (%)
👁 Coverage
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
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.
All these exceptions inherit from DbUpdateException for backwards compatibility.
First, install the package corresponding to your database:
dotnet add package EntityFrameworkCore.Exceptions.SqlServer
dotnet add package EntityFrameworkCore.Exceptions.MySql
dotnet add package EntityFrameworkCore.Exceptions.MySql.Pomelo
dotnet add package EntityFrameworkCore.Exceptions.PostgreSQL
dotnet add package EntityFrameworkCore.Exceptions.Sqlite
dotnet add package EntityFrameworkCore.Exceptions.Oracle
Next, in your DbContext OnConfiguring method call UseExceptionProcessor extension method:
class DemoContext : DbContext
{
public DbSet<Product> Products { get; set; }
public DbSet<ProductSale> ProductSale { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseExceptionProcessor();
}
}
You will now start getting different exception for different database error. For example, when a unique constraints fails you will get UniqueConstraintException exception:
using (var demoContext = new DemoContext())
{
demoContext.Products.Add(new Product
{
Name = "a",
Price = 1
});
demoContext.Products.Add(new Product
{
Name = "a",
Price = 1
});
try
{
demoContext.SaveChanges();
}
catch (UniqueConstraintException e)
{
//Handle exception here
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on EntityFrameworkCore.Exceptions.SqlServer:
| Package | Downloads |
|---|---|
|
GreatUtilities.Data
Essencial tools to agile development. |
|
|
Mii.Rinjani.Gateway.Commons
Package Description |
|
|
DotNetBrightener.DataAccess.EF
Package Description |
|
|
AuthPermissions.AspNetCore
Provides extra authorization and multi-tenant features to an ASP.NET Core application. |
|
|
ZC.Data.EntityFramework
Package Description |
Showing the top 5 popular GitHub repositories that depend on EntityFrameworkCore.Exceptions.SqlServer:
| Repository | Stars |
|---|---|
|
JonPSmith/AuthPermissions.AspNetCore
This library provides extra authorization and multi-tenant features to an ASP.NET Core application.
|
|
|
SSWConsulting/SSW.VerticalSliceArchitecture
An enterprise ready solution template for Vertical Slice Architecture. This template is just one way to apply the Vertical Slice Architecture.
|
|
|
neozhu/cleanaspire
CleanAspire is a cloud-native template built on Aspire, using .NET 10 Minimal APIs and Blazor WebAssembly to deliver lightweight, scalable PWAs with offline support.
|
|
|
SSWConsulting/SSW.CleanArchitecture
SSW Clean Architecture Template
|
|
|
marcominerva/SqlDatabaseVectorSearch
A Blazor Web App and Minimal API for performing RAG (Retrieval Augmented Generation) and vector search using the native VECTOR type in Azure SQL Database and Azure OpenAI.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.1 | 24,285 | 5/24/2026 |
| 10.0.0 | 189,476 | 3/19/2026 |
| 8.1.3 | 2,379,611 | 8/3/2024 |
| 8.1.2 | 360,858 | 3/22/2024 |
| 8.1.1 | 2,255 | 3/21/2024 |
| 8.1.0 | 21,898 | 3/16/2024 |
| 8.0.0.2 | 180,542 | 1/18/2024 |
| 8.0.0 | 64,332 | 12/11/2023 |
| 6.0.3.2 | 606,129 | 6/1/2023 |
| 6.0.3.1 | 517,039 | 9/3/2022 |
| 6.0.3 | 123,606 | 3/16/2022 |
| 3.1.4 | 543,547 | 2/12/2021 |
| 3.1.1 | 64,648 | 1/22/2020 |
| 1.0.1 | 34,629 | 6/11/2019 |
| 1.0.0 | 5,061 | 1/23/2019 |
| 0.1.0-beta | 1,251 | 12/5/2018 |
Update to .NET 8 and EF Core 8