Description
The application currently supports MySQL and PostgreSQL as sync source and target providers. This issue tracks the work needed to add Microsoft SQL Server (MSSQL) support.
The architecture already follows a clean provider pattern — each new database requires implementing a set of standard interfaces and wiring them into the existing factories and DI container, exactly as done for MySQL and PostgreSQL.
Tasks
- Add constant to DbProviders
Add public const string MsSql = "MSSQL"; to align with the existing naming convention used as keys in config and factories.
- Add NuGet package Microsoft.Data.SqlClient
Add the official Microsoft SQL Server client library to DbSyncEngine.Infrastructure.csproj.
- Extend DbConnectionFactory
Add a branch for DbProviders.MsSql that returns a SqlConnection.
- Implement MsSqlTableDataRepository
Implement ITableDataRepository with ReadChunkAsync and WriteChunkAsync using SqlConnection. Identifiers should be quoted with [square brackets] per T-SQL convention.
Register in TableDataRepositoryFactory and DependencyInjection.AddTableData().
- Implement MsSqlValueNormalizer
Implement IValueNormalizer to normalize raw values returned by the SQL Server ADO.NET driver to the application's internal format (e.g. proper bool, int, DateTime handling).
Register in ValueNormalizerFactory._map and DependencyInjection.AddNormalization().
- Implement MsSqlSchemaReader
Implement ISchemaReader.ReadAsync(SyncContext ctx) to read table metadata (column names, types, nullability, primary key) from information_schema.columns or sys.columns / sys.types and return a TableDefinition.
Register in SchemaReaderFactory._map and DependencyInjection.AddSchema().
- Implement MsSqlSchemaNormalizer
Implement ISchemaNormalizer.Normalize(TableDefinition, NormalizerContext) to map source column types to their SQL Server equivalents (e.g. text → nvarchar(MAX), tinyint(1) → bit).
Register in SchemaNormalizerFactory._map and DependencyInjection.AddNormalization().
- Implement MsSqlDdlGenerator
Implement ITargetDdlGenerator to produce T-SQL DDL statements for schema management: CREATE TABLE, DROP TABLE, table existence check, temp table naming, data copy, atomic table swap via sp_rename, post-swap cleanup, and identity
sequence sync.
Register in TargetDdlGeneratorFactory._map.
- Register all new types in DI
Add MsSqlSchemaReader, MsSqlSchemaNormalizer, MsSqlValueNormalizer, and MsSqlTableDataRepository to the appropriate extension methods in DependencyInjection.cs.
Acceptance Criteria
Description
The application currently supports MySQL and PostgreSQL as sync source and target providers. This issue tracks the work needed to add Microsoft SQL Server (MSSQL) support.
The architecture already follows a clean provider pattern — each new database requires implementing a set of standard interfaces and wiring them into the existing factories and DI container, exactly as done for MySQL and PostgreSQL.
Tasks
Add public const string MsSql = "MSSQL"; to align with the existing naming convention used as keys in config and factories.
Add the official Microsoft SQL Server client library to DbSyncEngine.Infrastructure.csproj.
Add a branch for DbProviders.MsSql that returns a SqlConnection.
Implement ITableDataRepository with ReadChunkAsync and WriteChunkAsync using SqlConnection. Identifiers should be quoted with [square brackets] per T-SQL convention.
Register in TableDataRepositoryFactory and DependencyInjection.AddTableData().
Implement IValueNormalizer to normalize raw values returned by the SQL Server ADO.NET driver to the application's internal format (e.g. proper bool, int, DateTime handling).
Register in ValueNormalizerFactory._map and DependencyInjection.AddNormalization().
Implement ISchemaReader.ReadAsync(SyncContext ctx) to read table metadata (column names, types, nullability, primary key) from information_schema.columns or sys.columns / sys.types and return a TableDefinition.
Register in SchemaReaderFactory._map and DependencyInjection.AddSchema().
Implement ISchemaNormalizer.Normalize(TableDefinition, NormalizerContext) to map source column types to their SQL Server equivalents (e.g. text → nvarchar(MAX), tinyint(1) → bit).
Register in SchemaNormalizerFactory._map and DependencyInjection.AddNormalization().
Implement ITargetDdlGenerator to produce T-SQL DDL statements for schema management: CREATE TABLE, DROP TABLE, table existence check, temp table naming, data copy, atomic table swap via sp_rename, post-swap cleanup, and identity
sequence sync.
Register in TargetDdlGeneratorFactory._map.
Add MsSqlSchemaReader, MsSqlSchemaNormalizer, MsSqlValueNormalizer, and MsSqlTableDataRepository to the appropriate extension methods in DependencyInjection.cs.
Acceptance Criteria