SyncLib.EntityFrameworkCore
8.3.2
dotnet add package SyncLib.EntityFrameworkCore --version 8.3.2
NuGet\Install-Package SyncLib.EntityFrameworkCore -Version 8.3.2
<PackageReference Include="SyncLib.EntityFrameworkCore" Version="8.3.2" />
<PackageVersion Include="SyncLib.EntityFrameworkCore" Version="8.3.2" />
<PackageReference Include="SyncLib.EntityFrameworkCore" />
paket add SyncLib.EntityFrameworkCore --version 8.3.2
#r "nuget: SyncLib.EntityFrameworkCore, 8.3.2"
#:package SyncLib.EntityFrameworkCore@8.3.2
#addin nuget:?package=SyncLib.EntityFrameworkCore&version=8.3.2
#tool nuget:?package=SyncLib.EntityFrameworkCore&version=8.3.2
SyncLib
This package has moved. The Dragonfire suite is now developed in a single repository:
outboxnet/Dragonfire. Visit it for the latest version and the full suite of packages.
A small, opinionated library for running scheduled data-synchronization jobs in .NET hosted apps. Each provider fetches data from somewhere (HTTP API, queue, file system, …), maps it to your domain entities, and persists it through a repository you control. The library handles scheduling, retries, circuit-breaking, and observability.
Packages
| Package | Purpose |
|---|---|
SyncLib.Abstractions |
Interfaces only — depend on this from your domain projects. |
SyncLib.Core |
Orchestrator, retry, circuit breaker, metrics, tracing. |
SyncLib.EntityFrameworkCore |
Optional EF Core implementations of ISyncStateStore and a generic repository. |
The entity types you sync do not carry sync metadata. Last-sync state
(timestamp, status, duration, error, counts) is persisted separately through
ISyncStateStore, so your domain model stays clean.
Quick start
services.AddSyncLibrary();
services.AddSyncProvider<WeatherDto, WeatherEntity>("weather")
.WithConfiguration(new ProviderSyncConfiguration
{
ProviderName = "weather",
SyncInterval = TimeSpan.FromMinutes(5)
})
.WithDataProvider<WeatherApiProvider>()
.WithRepository<WeatherRepository>()
.WithMapper<WeatherMapper>()
.Build();
// EF-backed sync state (recommended)
services.AddDbContext<AppDbContext>(o => o.UseSqlServer(connStr));
services.AddEntityFrameworkSyncStateStore<AppDbContext>();
Hosting models
SyncLib has two entry points and you pick whichever matches your host:
| Host | Register | Drives the schedule |
|---|---|---|
| ASP.NET / Worker Service | services.AddSyncLibrary() |
A built-in BackgroundService runs each provider on its SyncInterval. |
| Azure Functions / cron job / on-demand | services.AddSyncRunner() |
You invoke ISyncRunner.RunAllAsync() (or RunAsync(name)) — typically from a [TimerTrigger]. |
The same fetch → map → repository → state → metrics pipeline runs in both
modes. Your WithRepository<TYourRepo>() is what actually persists data, so
"the common logic" is shared regardless of who pulls the trigger.
Azure Functions example
// Program.cs
builder.Services.AddSyncRunner();
builder.Services.AddSyncProvider<WeatherDto, WeatherEntity>("weather")
.WithConfiguration(new ProviderSyncConfiguration { ProviderName = "weather", MaxRetryAttempts = 2 })
.WithDataProvider<WeatherApiProvider>()
.WithRepository<MyWeatherRepository>() // your own implementation
.WithMapper<WeatherMapper>()
.Build();
// SyncTimerFunction.cs
[Function("RunAllSyncs")]
public Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo timer, CancellationToken ct)
=> _runner.RunAllAsync(ct);
Full sample under samples/SyncLib.Sample.AzureFunctions.
Observability
- Sync state per provider — query
ISyncStateReaderfor last run time, status, duration, record count, and last error message. - Metrics —
synclib.sync.duration,synclib.sync.records,synclib.sync.failures,synclib.sync.successesexposed on theSyncLibMeter. - Tracing —
SyncLibActivitySourceemits a span per run withsync.provider,sync.records, andsync.statustags.
Sample app under samples/SyncLib.Sample.WebApi exposes a /sync/state
endpoint that returns the last-sync record for every provider.
License
MIT
| Product | Versions 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 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.10)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- SyncLib.Abstractions (>= 8.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.