All Projects → Giorgi → Entityframework.exceptions

Giorgi / Entityframework.exceptions

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

Projects that are alternatives of or similar to Entityframework.exceptions

Sqlprovider
A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
Stars: ✭ 423 (+59.02%)
Mutual labels:  oracle, mysql, postgresql, sqlite, sql-server
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-36.47%)
Mutual labels:  oracle, mysql, postgresql, sqlite, sqlite3
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-33.83%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Eosio sql plugin
EOSIO sql database plugin
Stars: ✭ 21 (-92.11%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Aioodbc
aioodbc - is a library for accessing a ODBC databases from the asyncio
Stars: ✭ 206 (-22.56%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (+675.19%)
Mutual labels:  oracle, mysql, postgresql, sqlite3
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+731.2%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Sqitch
Sensible database change management
Stars: ✭ 2,320 (+772.18%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+191.35%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Sqlfiddle3
New version based on vert.x and docker
Stars: ✭ 242 (-9.02%)
Mutual labels:  oracle, mysql, postgresql, sql-server
Pony
Pony Object Relational Mapper
Stars: ✭ 2,762 (+938.35%)
Mutual labels:  oracle, mysql, postgresql, sqlite
E Commerce Db
Database schema for e-commerce (webstores) sites.
Stars: ✭ 245 (-7.89%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (-52.26%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Directus
Open-Source Data Platform 🐰 — Directus wraps any SQL database with a real-time GraphQL+REST API and an intuitive app for non-technical users.
Stars: ✭ 13,190 (+4858.65%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Servicestack.ormlite
Fast, Simple, Typed ORM for .NET
Stars: ✭ 1,532 (+475.94%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Soci
Official repository of the SOCI - The C++ Database Access Library
Stars: ✭ 960 (+260.9%)
Mutual labels:  oracle, mysql, postgresql, sqlite3
Xo
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server
Stars: ✭ 2,974 (+1018.05%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Mormot
Synopse mORMot ORM/SOA/MVC framework
Stars: ✭ 607 (+128.2%)
Mutual labels:  oracle, mysql, postgresql, sqlite3
Zxw.framework.netcore
基于EF Core的Code First模式的DotNetCore快速开发框架,其中包括DBContext、IOC组件autofac和AspectCore.Injector、代码生成器(也支持DB First)、基于AspectCore的memcache和Redis缓存组件,以及基于ICanPay的支付库和一些日常用的方法和扩展,比如批量插入、更新、删除以及触发器支持,当然还有demo。欢迎提交各种建议、意见和pr~
Stars: ✭ 691 (+159.77%)
Mutual labels:  oracle, mysql, postgresql, sqlite
Chloe
A lightweight and high-performance Object/Relational Mapping(ORM) library for .NET --C#
Stars: ✭ 1,248 (+369.17%)
Mutual labels:  oracle, mysql, postgresql, sqlite

EntityFramework.Exceptions

EntityFramework.Exceptions

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

License AppVeyor AppVeyor Coverage Status Ko-Fi

Maintainability Rating Vulnerabilities Bugs Code Smells Duplicated Lines (%) Coverage

Build Stats

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.

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
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].