BaseSync 1.0.0

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

BaseSync

NuGet Version Downloads License .NET

A high-performance .NET library for bidirectional synchronization between online and offline SQL Server databases. BaseSync efficiently handles large datasets with 100,000+ rows through optimized bulk operations.

✨ Features

  • Bidirectional Synchronization: Pull from remote to local, then push from local to remote
  • High-Performance Design: Optimized for large tables (100,000+ rows) using:
    • Bulk insert operations with SqlBulkCopy
    • Set-based updates via temporary tables
    • Schema information caching
  • Intelligent Comparison: Only updates records that have actually changed
  • Zero Configuration: Automatically detects primary keys and table schemas
  • Detailed Reports: Comprehensive statistics for sync operations
  • Error Handling: Robust error handling with detailed feedback
  • Async First: Built with modern async patterns

📦 Installation

Install via NuGet Package Manager:

Install-Package BaseSync

Or via .NET CLI:

dotnet add package BaseSync

🚀 Quick Start

using BaseSync;

// Define connection strings
string localDb = "Server=localhost;Database=LocalDB;Trusted_Connection=True;TrustServerCertificate=True;";
string remoteDb = "Server=remote-server;Database=RemoteDB;User Id=user;Password=password;TrustServerCertificate=True;";

// Specify tables to synchronize
var tables = new List<string> { "Customers", "Orders", "Products" };

// Perform synchronization
SyncResult result = await BaseSync.SyncDataAsync(localDb, remoteDb, tables);

// Check results
foreach (var tableResult in result.TableResults) {
	Console.WriteLine($"Table: {tableResult.Key}");
	if (tableResult.Value.IsSuccess) {
		Console.WriteLine($"  Pull: {tableResult.Value.PullInserts} inserts, {tableResult.Value.PullUpdates} updates");
		Console.WriteLine($"  Push: {tableResult.Value.PushInserts} inserts, {tableResult.Value.PushUpdates} updates");
	} else {
		Console.WriteLine($"  Error: {tableResult.Value.ErrorMessage}");
	}
}

🔄 How It Works

BaseSync uses a sophisticated process to efficiently synchronize data:

  1. Schema Discovery: Automatically detects primary keys and columns for each table
  2. Schema Caching: Caches schema information to minimize database roundtrips
  3. Data Retrieval: Loads data from both source and destination databases
  4. Memory-Efficient Comparison: Creates dictionaries of destination rows indexed by primary key for O(1) lookups
  5. Change Detection: Identifies which rows need to be inserted or updated
  6. Bulk Operations:
    • Uses SqlBulkCopy for fast insertion of new rows
    • Creates temporary tables and performs set-based updates for changed rows
  7. Bidirectional Sync: First pulls from remote to local, then pushes from local to remote

📊 Performance Optimizations

BaseSync is engineered to handle large datasets efficiently:

  • Reduced Database Roundtrips: Performs bulk operations instead of row-by-row processing
  • Memory Management: Efficiently manages large datasets in memory
  • Set-Based Operations: Uses SQL's native strengths for updates via temp tables
  • Caching: Minimizes redundant schema queries

🛠️ Requirements

  • .NET 9.0 or higher
  • SQL Server databases (source and destination)
  • Tables must have primary keys defined

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

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

👨‍💻 About the Author

BaseSync is developed and maintained by AadiSoft.

📫 Contact

For any inquiries, please reach out to contact@aadi.vercel.app.


<div align="center"> <sub>Built with ❤️ by AadiSoft</sub> </div>

Product Compatible and additional computed target framework versions.
.NET 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 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. 
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.0 74 5/24/2025

First release functional and fast merging with Bulk update and insert