XyloCode.EFCore.Extensions 1.0.1

Prefix Reserved
dotnet add package XyloCode.EFCore.Extensions --version 1.0.1
                    
NuGet\Install-Package XyloCode.EFCore.Extensions -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XyloCode.EFCore.Extensions" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XyloCode.EFCore.Extensions" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="XyloCode.EFCore.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XyloCode.EFCore.Extensions --version 1.0.1
                    
#r "nuget: XyloCode.EFCore.Extensions, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XyloCode.EFCore.Extensions@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XyloCode.EFCore.Extensions&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=XyloCode.EFCore.Extensions&version=1.0.1
                    
Install as a Cake Tool

EF Core (Bulk) Extensions

An EF Core extension library for high-performance bulk data synchronization using SQL MERGE, supporting both IEnumerable<T> and IAsyncEnumerable<T> data sources.

The library is optimized for working with DevExpress XAF system fields (GCRecord, OptimisticLockField), as well as custom versioning and change-tracking fields (RowState, RowStamp). It supports state-aware record processing, including handling of deleted objects, and provides utilities for temporarily disabling foreign key constraint checks during synchronization operations.

Supported Databases

  • Microsoft SQL Server
  • Microsoft Azure SQL Database

How to use

using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using XyloCode.EFCore.Extensions;

namespace XyloCode.EFCore.Examples
{
    internal class SimpleFiller
    {
        private readonly SimpleEFCoreDbContext _dbContext;
        private readonly Channel<Country> _countryChannel = Channel.CreateUnbounded<Country>();

        public SimpleFiller(SimpleEFCoreDbContext dbContext)
        {
            _dbContext = dbContext;
        }


        public Task CountryMergeAsync(IEnumerable<Country> countries, CancellationToken cancellationToken = default)
        {
            var copyConfig = new EFCoreCopyConfig
            {
                BulkCopyTimeout = 300,
            };
            return _dbContext.MergeAsync(countries, copyConfig, cancellationToken);
        }


        private Task<int> CountryWorkerAsync(CancellationToken cancellationToken = default)
        {
            var entities = _countryChannel.Reader.ReadAllAsync(cancellationToken);
            var copyConfig = new EFCoreCopyConfig
            {
                BulkCopyTimeout = 0,
            };
            return _dbContext.MergeAsync(entities, copyConfig, cancellationToken);
        }


        public async Task AddCountryAsync(Country country, CancellationToken cancellationToken = default)
        {
            await _countryChannel.Writer.WriteAsync(country, cancellationToken);
        }
        
        public async Task RunAsync(CancellationToken cancellationToken = default)
        {
            await _dbContext.NoCheckConstraintAllAsync(typeof(Country), cancellationToken);

            var t = new Task[1];
            int i = 0;
            t[i++] = CountryWorkerAsync(cancellationToken);
            await Task.WhenAll(t);

            await _dbContext.CheckConstraintAllAsync(typeof(Country), cancellationToken);
        }
    }
}

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 42 11/9/2026
1.0.0 95 11/2/2026

Fixed numerous bugs and improved overall stability. Renamed configuration properties and methods for better consistency and clarity. Development is ongoing.