Transformations.EntityFramework 3.1.0

dotnet add package Transformations.EntityFramework --version 3.1.0
                    
NuGet\Install-Package Transformations.EntityFramework -Version 3.1.0
                    
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="Transformations.EntityFramework" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Transformations.EntityFramework" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Transformations.EntityFramework" />
                    
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 Transformations.EntityFramework --version 3.1.0
                    
#r "nuget: Transformations.EntityFramework, 3.1.0"
                    
#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 Transformations.EntityFramework@3.1.0
                    
#: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=Transformations.EntityFramework&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Transformations.EntityFramework&version=3.1.0
                    
Install as a Cake Tool

Transformations.EntityFramework

Resilient SaveChanges, structured audit extraction, and IQueryable CSV export for EF Core — without subclassing DbContext or adding custom interceptors.

NuGet .NET 8 | 9 | 10

📖 Overview

Transformations.EntityFramework equips any standard DbContext with resilient saves, structured audit extraction, and IQueryable CSV export — without subclassing DbContext or writing custom interceptors.

🚀 Why Transformations.EntityFramework?

EF Core is powerful, but two things require disproportionate effort: handling transient connectivity drops (Azure SQL throttling, network blips) and capturing exactly which properties changed before a save. The standard workarounds — custom execution strategies, SaveChanges overrides, manual ChangeTracker loops — mean boilerplate in every project. These extensions inject both capabilities as simple extension method calls on any existing DbContext.

📦 Install

<PackageReference Include="Transformations.EntityFramework" Version="3.1.0.0" />

💡 What's Included

Resilient SaveChanges

Wraps SaveChangesAsync with exponential backoff. By default it retries only transient SQL Server faults, such as deadlocks, timeouts and Azure throttling, as classified by Transformations.Sql. A constraint violation or a concurrency conflict is thrown on the first attempt.

// 4 retries, 250ms initial delay (doubles each attempt)
int rowsAffected = await context.SaveChangesWithRetryAsync(
    retryCount: 4,
    initialDelay: TimeSpan.FromMilliseconds(250));

// With cancellation token
await context.SaveChangesWithRetryAsync(cancellationToken: ct);

// Opt in to retrying the exception types you name, such as SQLite's busy error. Other exceptions are thrown immediately.
await context.SaveChangesWithRetryAsync(
    retryCount: 4,
    initialDelay: TimeSpan.FromMilliseconds(250),
    retryOnExceptions: new[] { typeof(SqliteException) },
    failFastExceptions: null);

SQLite and other providers have no transient codes in the default. A busy database is not retried unless you opt in as above.

ChangeTracker Audit Extraction

Captures structured AuditEntry records from EF Core's ChangeTracker before calling SaveChanges. After save, entity states are reset — so capture first.

// Capture all pending Added/Modified/Deleted changes
var audit = context.GetAuditEntries();

// Or filter to a specific state
var modified = context.GetAuditEntries(EntityState.Modified);

await context.SaveChangesWithRetryAsync();

foreach (var entry in modified)
{
    logger.LogInformation("{Entity} [{Key}] — {Prop}: {Old} → {New}",
        entry.EntityType,
        entry.KeyValues,
        entry.PropertyName,
        entry.OriginalValue,
        entry.CurrentValue);
}

AuditEntry properties: EntityType, State, PropertyName, OriginalValue, CurrentValue, KeyValues, TimestampUtc.

IQueryable → CSV Export

ToCsvAsync writes RFC 4180 CSV for objects (entities, records, or anonymous projections): a header row of the public readable scalar properties, then one record per row. Records end with \r\n. A field containing a comma, a quote or a line break is quoted, with embedded quotes doubled. Null values are empty fields. Nested objects and collections are not written.

string csv = await context.Users
    .Where(u => u.IsActive)
    .Select(u => new { u.Id, u.Name, u.Email })
    .ToCsvAsync();
// Id,Name,Email
// 1,"Smith, Jo",jo@example.test

A scalar element type, such as string or int, has no column names, so ToCsvAsync throws ArgumentException for it. Use ToJoinedStringAsync instead. It joins each element's ToString() with a separator. It writes no header and does not quote, so a value that contains the separator is not escaped.

string emails = await context.Users
    .Select(u => u.Email)
    .ToJoinedStringAsync();            // comma-separated

string names = await context.Users
    .Select(u => u.Name)
    .ToJoinedStringAsync(';');         // custom separator

The old ToCsvAsync(separator) overload is obsolete. It forwards to ToJoinedStringAsync.


🛠 API Reference

Class Purpose Key Members
DbContextResilienceExtensions Resilient saves SaveChangesWithRetryAsync(retryCount, initialDelay, ct) (transient faults only), SaveChangesWithRetryAsync(retryCount, initialDelay, retryOnExceptions, failFastExceptions, ct)
ChangeTrackerAuditExtensions Audit capture GetAuditEntries(), GetAuditEntries(EntityState)
QueryableCsvExtensions CSV export ToCsvAsync<T>(ct) (RFC 4180, objects only), ToJoinedStringAsync<T>(ct), ToJoinedStringAsync<T>(separator, ct)
AuditEntry Audit record EntityType, State, PropertyName, OriginalValue, CurrentValue, KeyValues, TimestampUtc

📦 Dependencies

  • Transformations.Core
  • Microsoft.EntityFrameworkCore

License

PolyForm Strict 1.0.0 — Copyright © 2026 opentail.net

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Transformations.EntityFramework:

Package Downloads
Transformations

Modern .NET transformation helpers for conversion, strings, collections, data, web, diagnostics, batching, and resilience.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 93 10/27/2026
3.0.0 96 10/27/2026
2.0.5.1 115 10/23/2026
2.0.4.6 112 10/11/2026
2.0.4.5 111 10/10/2026
2.0.4.2 160 7/7/2026
2.0.4.1 171 7/7/2026
2.0.0 149 4/10/2026