AppXDev.SyncEntityFramework 0.6.1

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

AppXDev.SyncEntityFramework

NuGet License

A bidirectional Entity Framework sync framework for distributed retail systems. Synchronize data between a central server and multiple store locations using SQL Server and message-based communication.

🚀 Features

  • Bidirectional Sync: Push and pull changes between Central HQ and Store locations.
  • Conflict Resolution: Configurable strategies (LastWriteWins, Merge, Manual).
  • Resilient Architecture: Handles offline scenarios with local queuing and retry policies.
  • Real-time Dashboard: Visual monitoring of data propagation across nodes.
  • EF Core Integration: Seamlessly hooks into EF Core SaveChanges for automatic change tracking.
  • Docker Ready: Full environment orchestration with Docker Compose.

🏁 Quick Start (Run the Demo)

The easiest way to see the framework in action is to run the full Docker environment, which spins up:

  1. Central API: The HQ server.
  2. Store Agents (A & B): Two independent store nodes.
  3. Dashboard: A Blazor UI to visualize and manipulate data.
  4. Infrastructure: SQL Server and RabbitMQ.

Prerequisites

Steps

  1. Clone the repository

    git clone https://github.com/qdev89/AppXDev.SyncEntityFramework.git
    cd AppXDev.SyncEntityFramework
    
  2. Start the Environment

    docker-compose up --build
    

    Wait for all services to start. SQL Server initialization may take a minute.

  3. Access the Dashboard Open your browser to: http://localhost:5200


🖥️ Using the Dashboard

The Sync Dashboard allows you to simulate real-world retail scenarios:

1. Visualizing Sync

  • Three Columns: Represents the databases of Central Server, Store A, and Store B.
  • Auto-Refresh: The UI updates every 10 seconds to show data propagating between nodes.
  • Status Indicators:
    • <span style="color:green">Green Badge</span>: High Stock
    • <span style="color:orange">Yellow Badge</span>: Low Stock
    • <span style="color:red">Red Badge</span>: Out of Stock

2. Simulating Actions

  • Add to Central: Simulates an HQ product launch. Watch it appear in Store A and Store B after a few seconds.
  • Add to Store A: Simulates a local store creation. It will sync to Central, then down to Store B.
  • Reset / Clean Up: Wipes all data from all databases to start fresh.

📦 Installation (For Developers)

To use the SDK in your own project:

# Full SDK
dotnet add package AppXDev.SyncEntityFramework

# Or individual packages
dotnet add package AppXDev.SyncEntityFramework.Domain
dotnet add package AppXDev.SyncEntityFramework.Application

1. Define Sync Entities

Inherit from SyncEntity to enable tracking.

using AppXDev.Sync.Domain.Entities;

[SyncEntity(ConflictStrategy.LastWriteWins, SyncPriority.High)]
public class Product : SyncEntity
{
    public string Name { get; set; }
    public decimal Price { get; set; }
}

2. Register Services

In Program.cs:

// Add Core Sync Services
builder.Services.AddScoped<IChangeTracker, EfCoreChangeTracker>();
builder.Services.AddScoped<ISyncEngine, SyncService>();

// Add Interceptor for Auto-Tracking
builder.Services.AddSingleton<SyncSaveChangesInterceptor>(sp => 
    new SyncSaveChangesInterceptor("STORE-001"));

// Register DbContext with Interceptor
builder.Services.AddDbContext<AppDbContext>((sp, options) => {
    options.UseSqlServer("...");
    options.AddInterceptors(sp.GetRequiredService<SyncSaveChangesInterceptor>());
});

🏗️ Architecture

The solution follows a Hub-and-Spoke architecture:

graph TD
    Central[Central API]
    StoreA[Store A Agent]
    StoreB[Store B Agent]
    RabbitMQ((RabbitMQ))
    
    StoreA <-->|HTTP Pull/Push| Central
    StoreB <-->|HTTP Pull/Push| Central
    Central -.->|Notify| RabbitMQ
    RabbitMQ -.->|Wake Up| StoreA
    RabbitMQ -.->|Wake Up| StoreB
  • Central API: The source of truth. Exposes endpoints for Pull (get changes) and Push (receive changes).
  • Store Agent: A background worker that periodically polls Central for updates and pushes local changes.
  • SyncChangeApplicator: A service that deserializes JSON change sets and applies them to the actual Entity tables.

📂 Project Structure

  • src/AppXDev.Sync.Domain: Core entities and interfaces.
  • src/AppXDev.Sync.Application: Business logic and sync orchestration.
  • src/AppXDev.Sync.Infrastructure: EF Core and RabbitMQ implementations.
  • src/AppXDev.Sync.Central.Api: The HQ Web API.
  • src/AppXDev.Sync.Store.Agent: The background worker for stores.
  • src/AppXDev.Sync.Demo.Dashboard: Blazor UI for visualization.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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
0.6.1 118 1/4/2026
0.5.0 116 1/3/2026
0.4.2 112 1/3/2026