EntityFrameworkCore.Exceptions.Sqlite
8.0.0
See the version list below for details.
dotnet add package EntityFrameworkCore.Exceptions.Sqlite --version 8.0.0
NuGet\Install-Package EntityFrameworkCore.Exceptions.Sqlite -Version 8.0.0
<PackageReference Include="EntityFrameworkCore.Exceptions.Sqlite" Version="8.0.0" />
paket add EntityFrameworkCore.Exceptions.Sqlite --version 8.0.0
#r "nuget: EntityFrameworkCore.Exceptions.Sqlite, 8.0.0"
// Install EntityFrameworkCore.Exceptions.Sqlite as a Cake Addin #addin nuget:?package=EntityFrameworkCore.Exceptions.Sqlite&version=8.0.0 // Install EntityFrameworkCore.Exceptions.Sqlite as a Cake Tool #tool nuget:?package=EntityFrameworkCore.Exceptions.Sqlite&version=8.0.0
EntityFramework.Exceptions
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
Entity Framework Community Standup Live Show
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.
All these exceptions inherit from DbUpdateException
for backwards compatibility.
How do I get started?
First, install the package corresponding to your database:
PM> Install-Package EntityFrameworkCore.Exceptions.SqlServer
PM> Install-Package EntityFrameworkCore.Exceptions.MySql
PM> Install-Package EntityFrameworkCore.Exceptions.MySql.Pomelo
PM> Install-Package EntityFrameworkCore.Exceptions.PostgreSQL
PM> Install-Package EntityFrameworkCore.Exceptions.Sqlite
PM> Install-Package EntityFrameworkCore.Exceptions.Oracle
Or:
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 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- EntityFrameworkCore.Exceptions.Common (>= 8.0.0)
- Microsoft.Data.SQLite (>= 8.0.0)
-
net8.0
- EntityFrameworkCore.Exceptions.Common (>= 8.0.0)
- Microsoft.Data.SQLite (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on EntityFrameworkCore.Exceptions.Sqlite:
Package | Downloads |
---|---|
AuthPermissions.AspNetCore
Provides extra authorization and multi-tenant features to an ASP.NET Core application. |
|
Qiqigou.MyEFCore
EFCore的包装库 |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on EntityFrameworkCore.Exceptions.Sqlite:
Repository | Stars |
---|---|
neozhu/CleanArchitectureWithBlazorServer
This is a repository for creating a Blazor Server dashboard application following the principles of Clean Architecture
|
|
JonPSmith/AuthPermissions.AspNetCore
This library provides extra authorization and multi-tenant features to an ASP.NET Core application.
|
|
linkdotnet/BlogExamples
Contains all of my examples from various blog posts
|
Update to .NET 8 and EF Core 8