|
| 1 | +# SharpCoreDB.Provider.Sync — Add-In Pattern Updates |
| 2 | + |
| 3 | +**Date:** 2025-01 |
| 4 | +**Status:** Implementation plans updated to follow add-in pattern |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## What Changed |
| 9 | + |
| 10 | +The Dotmim.Sync provider implementation plan was updated to follow the **add-in pattern** established by `SharpCoreDB.Provider.YesSql`. This ensures consistency across the SharpCoreDB ecosystem and enables proper NuGet packaging and dependency injection. |
| 11 | + |
| 12 | +### Project Naming |
| 13 | + |
| 14 | +| Before | After | Reason | |
| 15 | +|---|---|---| |
| 16 | +| `SharpCoreDB.Sync` | `SharpCoreDB.Provider.Sync` | Consistent with YesSql/other provider naming | |
| 17 | +| `SharpCoreDB.Sync.Tests` | `SharpCoreDB.Provider.Sync.Tests` | Follows standard test project naming | |
| 18 | + |
| 19 | +### Package Identity |
| 20 | + |
| 21 | +| Aspect | Value | |
| 22 | +|---|---| |
| 23 | +| **NuGet Package ID** | `SharpCoreDB.Provider.Sync` | |
| 24 | +| **Assembly Name** | `SharpCoreDB.Provider.Sync` | |
| 25 | +| **Namespace** | `SharpCoreDB.Provider.Sync` | |
| 26 | +| **Version** | `1.0.0` (independent from core) | |
| 27 | + |
| 28 | +### Dependency Injection Integration |
| 29 | + |
| 30 | +Added formal DI extension pattern: |
| 31 | + |
| 32 | +```csharp |
| 33 | +// Program.cs |
| 34 | +services.AddSharpCoreDBSync( |
| 35 | + connectionString: "Path=C:\\data\\local.scdb;Password=secret", |
| 36 | + options: opts => { |
| 37 | + opts.EnableAutoTracking = true; |
| 38 | + opts.TombstoneRetentionDays = 30; |
| 39 | + }); |
| 40 | + |
| 41 | +// Later in code |
| 42 | +var provider = serviceProvider.GetRequiredService<SharpCoreDBSyncProvider>(); |
| 43 | +``` |
| 44 | + |
| 45 | +### Project Structure |
| 46 | + |
| 47 | +**New folders in `src/SharpCoreDB.Provider.Sync/`:** |
| 48 | + |
| 49 | +``` |
| 50 | +Extensions/ |
| 51 | + ├─ SyncServiceCollectionExtensions.cs ← DI registration |
| 52 | + └─ SyncProviderFactory.cs ← Factory pattern |
| 53 | +``` |
| 54 | + |
| 55 | +These follow the Microsoft.Extensions.DependencyInjection conventions. |
| 56 | + |
| 57 | +### Documentation Updates |
| 58 | + |
| 59 | +1. **Phase 1.4**: Detailed DI extension implementation task with: |
| 60 | + - Service registration pattern |
| 61 | + - Configuration options |
| 62 | + - Usage examples |
| 63 | + |
| 64 | +2. **Phase 6.2**: README updated to show: |
| 65 | + - Installation via NuGet |
| 66 | + - DI setup in Program.cs |
| 67 | + - Multi-tenant filtering |
| 68 | + - Sample code |
| 69 | + |
| 70 | +3. **Phase 6.5**: Main README now links to: |
| 71 | + - `SharpCoreDB.Provider.Sync` package |
| 72 | + - DI integration examples |
| 73 | + |
| 74 | +### Technical Decisions |
| 75 | + |
| 76 | +Added to TD log: |
| 77 | + |
| 78 | +| TD | Decision | Rationale | |
| 79 | +|---|---|---| |
| 80 | +| TD-7 | Add-in pattern (SharpCoreDB.Provider.Sync) | Consistent with YesSql; enables optional installation | |
| 81 | +| TD-8 | Use DI for provider factory | Microsoft.Extensions.DependencyInjection pattern | |
| 82 | + |
| 83 | +### Milestones |
| 84 | + |
| 85 | +Added new M2 milestone: |
| 86 | + |
| 87 | +| M2 | DI Integration Works | `services.AddSharpCoreDBSync()` registers and resolves from container | Week 2 | |
| 88 | + |
| 89 | +### Risk Mitigations |
| 90 | + |
| 91 | +Added to risk register: |
| 92 | + |
| 93 | +- **DI container misconfiguration** — Comprehensive examples, XML docs, sample project |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## Alignment with Existing Providers |
| 98 | + |
| 99 | +### SharpCoreDB.Provider.YesSql Pattern |
| 100 | + |
| 101 | +```csharp |
| 102 | +services.AddYesSqlDataStore(c => |
| 103 | + c.UseSqlite("Data Source=..." /* ... */)); |
| 104 | + |
| 105 | +// SharpCoreDB.Provider.Sync follows the same pattern: |
| 106 | +services.AddSharpCoreDBSync("Path=C:\\...;Password=..."); |
| 107 | +``` |
| 108 | + |
| 109 | +### Benefits of Add-In Pattern |
| 110 | + |
| 111 | +✅ **Consistency** — Matches the ecosystem's provider model |
| 112 | +✅ **Optional** — Users choose to install only what they need |
| 113 | +✅ **Composable** — Integrates naturally with DI containers |
| 114 | +✅ **Discoverable** — Clear `SharpCoreDB.Provider.*` naming |
| 115 | +✅ **Versioning** — Independent versioning from core (core v1.3.5 ≠ provider v1.0.0) |
| 116 | +✅ **Packaging** — Proper separation of concerns for NuGet |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## File References |
| 121 | + |
| 122 | +- **Updated:** `docs/proposals/DOTMIM_SYNC_IMPLEMENTATION_PLAN.md` |
| 123 | + - Phase 1.1: Project structure (add-in naming) |
| 124 | + - Phase 1.4: DI extensions task (new/expanded) |
| 125 | + - Phase 4: Test project paths updated |
| 126 | + - Phase 6: NuGet metadata and README examples |
| 127 | + - Technical decisions: Added TD-7, TD-8 |
| 128 | + |
| 129 | +- **Updated:** `docs/proposals/DOTMIM_SYNC_PROVIDER_PROPOSAL.md` |
| 130 | + - Section 8: Project structure (add-in pattern) |
| 131 | + - Dependencies: Unchanged |
| 132 | + - Risks: Added DI misconfiguration mitigation |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +## Implementation Impact |
| 137 | + |
| 138 | +### Phase 1 (Week 2) |
| 139 | + |
| 140 | +Task 1.4 now includes implementing: |
| 141 | +- `SyncServiceCollectionExtensions.cs` with `AddSharpCoreDBSync()` method |
| 142 | +- `SyncProviderFactory.cs` for instance creation |
| 143 | +- Configuration options class (`SyncProviderOptions`) |
| 144 | + |
| 145 | +### Phase 6 (Week 8-9) |
| 146 | + |
| 147 | +NuGet packaging now includes: |
| 148 | +- Package ID: `SharpCoreDB.Provider.Sync` |
| 149 | +- Multi-RID support (standard across all providers) |
| 150 | +- Proper dependencies and metadata |
| 151 | + |
| 152 | +### Documentation |
| 153 | + |
| 154 | +README examples now show DI-first approach: |
| 155 | +```csharp |
| 156 | +// Instead of manual instantiation: |
| 157 | +var provider = new SharpCoreDBSyncProvider { ConnectionString = "..." }; |
| 158 | + |
| 159 | +// Use DI: |
| 160 | +services.AddSharpCoreDBSync("..."); |
| 161 | +var provider = serviceProvider.GetRequiredService<SharpCoreDBSyncProvider>(); |
| 162 | +``` |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## No Breaking Changes |
| 167 | + |
| 168 | +These updates are **planning-level changes** — the actual implementation hasn't started yet. When Phase 1 implementation begins, it will follow the add-in pattern from the start, so no breaking changes will occur later. |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## Next Steps |
| 173 | + |
| 174 | +1. ✅ **Planning**: Both proposal and implementation plan updated (THIS DOCUMENT) |
| 175 | +2. ⏳ **Phase 0**: Execute prerequisite tasks in SharpCoreDB core |
| 176 | +3. ⏳ **Phase 1**: Create `SharpCoreDB.Provider.Sync` project with DI integration |
| 177 | +4. ⏳ **Phase 2-6**: Complete remaining phases per the implementation plan |
| 178 | + |
| 179 | +For questions or clarifications, see the full plans: |
| 180 | +- [DOTMIM_SYNC_PROVIDER_PROPOSAL.md](./DOTMIM_SYNC_PROVIDER_PROPOSAL.md) |
| 181 | +- [DOTMIM_SYNC_IMPLEMENTATION_PLAN.md](./DOTMIM_SYNC_IMPLEMENTATION_PLAN.md) |
0 commit comments