NuExt.System.Data is a lightweight, provider-independent data access foundation for .NET applications and application frameworks, combining practical ADO.NET extensions, explicit database context ownership, reusable DAL abstractions, and deterministic database migration orchestration.
- Provider-independent — common DAL and migration contracts remain separate from provider-specific connections, transactions, and history storage
- Ownership-aware — DAL operations explicitly distinguish owned contexts from caller-provided contexts
- Composable — independent operations and larger transactional units of work use the same DAL implementation
- Migration-safe — configured migrations and applied history are validated as one ordered sequence before pending changes run
- ADO.NET-focused — typed reader, row, and table helpers without an ORM or tracking model
- Consistent across runtimes — a stable API surface across modern .NET, .NET Standard, and .NET Framework
- Dependency-light — no required ORM, hosting model, dependency injection container, or database provider
NuExt.System.Data is intended for application and framework authors who need:
- a small reusable foundation above ADO.NET rather than a full ORM;
- explicit ownership and transaction boundaries in data access code;
- the same DAL methods for standalone operations and caller-controlled units of work;
- deterministic migration orchestration with provider-specific execution;
- strict validation of migration ordering and applied history;
- compatibility across modern .NET and legacy .NET Framework targets.
DataReaderExtensionsadds name-based typed accessors and nullable getters for older targets.DataRowExtensionsprovides typed and nullable conversions by index, name,DataColumn, orDataRowVersion.DataTableExtensionsprovides focused table operations without object tracking.- Compatibility implementations resolve column names to ordinals and preserve provider behavior.
IDbContextdefines the lifetime contract for provider-specific database contexts.IDbContextExecutor<TDbContext>creates and executes owned context scopes while also supporting operations over existing contexts.DalBase<TDbContext>centralizes DAL execution and exposes the same synchronous and asynchronous operation model for owned and borrowed contexts.DbContextExtensionsadds focused helpers around context execution without hiding ownership boundaries.
The DAL infrastructure supports two execution models:
- Owned context — when no context is supplied, the provider-specific executor creates and owns the context, including connection lifetime, transaction completion, and cleanup.
- Borrowed context — when an existing context is supplied, the DAL participates in the caller's unit of work without committing, rolling back, or disposing that context.
This design allows a DAL operation to run independently or compose with other operations inside one caller-controlled transaction without duplicating data access logic.
Migration orchestration is provider-independent; transaction handling and history persistence are provider-specific.
DbMigration<TContext>represents an ordered schema or data change with a stable identifier.DbMigrationContextcarries cancellation and provides a base for provider-specific state.DbMigrator<TContext>validates migration configuration and history before applying pending migrations.IDbMigrationExecutor<TContext>defines the provider-specific execution and transaction boundary.IDbMigrationHistory<TContext>defines migration history storage.AppliedDbMigrationrecords the sequence, identifier, UTC application time, and optional version.
Before executing pending migrations, the migrator verifies that:
- configured migration identifiers are non-empty and unique;
- applied history does not contain more entries than the current configuration;
- applied sequence numbers are contiguous and one-based;
- every applied identifier matches the configured migration at the same position.
This treats migration history as a strict prefix of the configured migration sequence and prevents silently continuing from reordered, removed, duplicated, or otherwise inconsistent migrations.
- Cancellation is checked before execution and before each pending migration.
- The migration context passes the cancellation token to provider code and migrations.
- A migration is recorded only after its
Upoperation completes successfully. IDbMigrationExecutor<TContext>controls transactions and keeps migration history consistent.
- .NET Standard 2.0+, .NET 8/9/10, and .NET Framework 4.6.2+
- Works with provider-specific implementations built on ADO.NET
- Includes selected ADO.NET API backports for older targets
- Does not require Entity Framework or another ORM
Via NuGet:
dotnet add package NuExt.System.DataOr via Visual Studio:
- Go to
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.... - Search for
NuExt.System.Data. - Click "Install".
For a complete provider implementation, transaction strategy, migration history store, and usage example, see:
- NuExt.System
- NuExt.System.Data.SQLite
- NuExt.Minimal.Mvvm
- NuExt.Minimal.Mvvm.SourceGenerator
- NuExt.Minimal.Behaviors.Wpf
- NuExt.Minimal.Mvvm.Wpf
- NuExt.Minimal.Mvvm.MahApps.Metro
Issues and PRs are welcome. Keep changes minimal and performance-conscious.
MIT. See LICENSE.