SkillAgentSearch skills...

FlexLabs.Upsert

FlexLabs.Upsert is a library that brings UPSERT functionality to common database providers for Entity Framework in their respective native SQL syntax

Install / Use

/learn @artiomchi/FlexLabs.Upsert
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

FlexLabs.Upsert

Build status FlexLabs.EntityFrameworkCore.Upsert on NuGet

<!-- CI build: [![FlexLabs.EntityFrameworkCore.Upsert on MyGet](https://img.shields.io/myget/artiomchi/vpre/FlexLabs.EntityFrameworkCore.Upsert.svg)](https://github.com/artiomchi/FlexLabs.Upsert/wiki/CI-Builds) -->

This library adds basic support for "Upsert" operations to EF Core.

Uses INSERT … ON CONFLICT DO UPDATE in PostgreSQL/Sqlite, MERGE in SqlServer & Oracle and INSERT INTO … ON DUPLICATE KEY UPDATE in MySQL.

Also supports injecting sql command runners to add support for other providers

A typical upsert command could look something like this:

DataContext.DailyVisits
    .Upsert(new DailyVisit
    {
        UserID = userID,
        Date = DateTime.UtcNow.Date,
        Visits = 1,
    })
    .On(v => new { v.UserID, v.Date })
    .WhenMatched(v => new DailyVisit
    {
        Visits = v.Visits + 1,
    })
    .RunAsync();

In this case, the upsert command will ensure that a new DailyVisit will be added to the database. If a visit with the same UserID and Date already exists, it will be updated by incrementing it's Visits value by 1.

Please read our Usage page for more examples

View on GitHub
GitHub Stars669
CategoryData
Updated9d ago
Forks106

Languages

C#

Security Score

95/100

Audited on Mar 19, 2026

No findings