NuExt.System.Data.SQLite
0.8.0
Prefix Reserved
See the version list below for details.
dotnet add package NuExt.System.Data.SQLite --version 0.8.0
NuGet\Install-Package NuExt.System.Data.SQLite -Version 0.8.0
<PackageReference Include="NuExt.System.Data.SQLite" Version="0.8.0" />
<PackageVersion Include="NuExt.System.Data.SQLite" Version="0.8.0" />
<PackageReference Include="NuExt.System.Data.SQLite" />
paket add NuExt.System.Data.SQLite --version 0.8.0
#r "nuget: NuExt.System.Data.SQLite, 0.8.0"
#:package NuExt.System.Data.SQLite@0.8.0
#addin nuget:?package=NuExt.System.Data.SQLite&version=0.8.0
#tool nuget:?package=NuExt.System.Data.SQLite&version=0.8.0
NuExt.System.Data.SQLite
NuExt.System.Data.SQLite extends System.Data.SQLite with process-local connection synchronization, explicit transaction and database context management, lightweight DAL infrastructure, and transactional database migrations with validated history tracking for modern .NET applications.
Features
- Synchronized Database Access: Coordinates operations through reentrant process-local locks, including shared locks for multiple connections targeting the same database.
- Transaction Scope Management: Provides explicit transaction state tracking, prevents nested transactions, and supports coordinated execution through reentrant connection locks.
- Database Context Management: Manages connection state, transaction lifetime, commit, rollback, and deterministic resource cleanup.
- ADO.NET Utilities: Provides helpers for commands, parameters, readers, data adapters, schema inspection, and common SQLite operations.
- Database Migrations: Applies ordered schema and data migrations transactionally, records migration history with optional version metadata, and validates that the applied history matches the configured migration sequence.
Important Considerations
SQLite allows multiple readers but serializes writes according to the configured journal mode and transaction state. Long-running write transactions can delay other operations and increase the likelihood of lock timeouts.
The library's shared lock is intentionally process-local. Applications that access the same database from multiple processes must still rely on SQLite locking, timeouts, and appropriate journal configuration.
Concurrency and Locking
SQLiteDbConnection uses a reentrant process-local lock to coordinate database operations. When shared locking is enabled, connections targeting the same database use the same lock. When shared locking is disabled, each wrapper connection uses its own lock.
This coordination helps reduce competing write operations and "database is locked" errors originating within the same process. It does not replace SQLite file locking and cannot coordinate access from other processes or external database tools.
Transactions can be used directly when the caller guarantees exclusive connection access. Concurrent or reentrant scenarios should execute the entire transaction lifetime within AcquireLock or use ExecuteInTransaction.
Quick Examples
Transaction Example
connection.ExecuteInTransaction(transaction =>
{
connection.ExecuteNonQuery(
"UPDATE Movies SET Title = @Title WHERE Id = @Id",
CommandBehavior.Default,
cancellationToken,
DbType.String.CreateInputParam("@Title", title),
DbType.Int64.CreateInputParam("@Id", id));
transaction.Commit();
}, cancellationToken);
The callback is responsible for committing the transaction or explicitly rolling it back when the operation completes normally. If the callback throws while the transaction is still active, the transaction is rolled back automatically without replacing the original exception with a rollback error.
Migration Example
internal sealed class CreateMoviesSchema_0001 : SQLiteDbMigration
{
public override string Id => "0001_CreateMoviesSchema";
public override void Up(SQLiteDbMigrationContext context)
{
context.ExecuteNonQuery(
"""
CREATE TABLE Movies (
Id INTEGER PRIMARY KEY,
Title TEXT NOT NULL
);
""");
}
}
SQLiteDbMigration[] migrations =
[
new CreateMoviesSchema_0001()
];
migrations.Migrate(CreateConnection, "1.0.0", cancellationToken);
Migrations are applied in the order in which they are registered. Applied migrations are recorded in the __nuext_migrations table together with their application time and optional version information. When a connection factory is used, the complete migration batch is executed within a synchronized transaction and is rolled back if any migration fails. Migrations can also use an existing SQLiteDbContext, allowing the caller to include migrations and application operations in the same transaction and retain responsibility for committing or rolling it back.
Commonly Used Types
System.Data.SQLite.SQLiteDalBase: Base class for SQLite DAL implementations with synchronized provider-managed context execution and access to connection creation for custom scenarios.System.Data.SQLite.SQLiteDbConnection: Wraps SQLite connections with process-local synchronization, transaction coordination, command execution, schema inspection, and common data access utilities.System.Data.SQLite.SQLiteDbContext: Manages connection state and transaction lifetime, with optional validation that the connection lock remains held for the lifetime of the context.System.Data.SQLite.SQLiteDbMigration: Base class for defining ordered SQLite schema and data migrations.System.Data.SQLite.SQLiteDbMigrationContext: Provides the execution context used by SQLite migrations.System.Data.SQLite.SQLiteDbTransaction: Wraps SQLite transactions with explicit state tracking, commit and rollback operations, and transaction lifetime diagnostics.
Installation
Via NuGet:
dotnet add package NuExt.System.Data.SQLite
Or via Visual Studio:
- Go to
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.... - Search for
NuExt.System.Data.SQLite. - Click "Install".
Compatibility
.NET Standard 2.0+, .NET 8/9/10 and .NET Framework 4.6.2+
Usage Examples
For examples of how to use these classes, see the samples. These samples provide practical guidance on implementing the library's features in real-world scenarios.
Ecosystem
- NuExt.Minimal.Mvvm
- NuExt.Minimal.Mvvm.SourceGenerator
- NuExt.Minimal.Behaviors.Wpf
- NuExt.Minimal.Mvvm.Wpf
- NuExt.Minimal.Mvvm.MahApps.Metro
- NuExt.System
- NuExt.System.Data
Contributing
Issues and PRs are welcome. Keep changes minimal and performance-conscious.
License
MIT. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 is compatible. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
-
.NETFramework 4.7.1
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
-
.NETStandard 2.0
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
-
.NETStandard 2.1
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
-
net10.0
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
-
net8.0
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
-
net9.0
- NuExt.System.Data (>= 0.8.0)
- System.Data.SQLite.Core (>= 1.0.119)
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.8.2 | 0 | 10/13/2026 |
| 0.8.1 | 0 | 10/13/2026 |
| 0.8.0 | 66 | 10/12/2026 |
| 0.7.6 | 91 | 10/2/2026 |
| 0.7.5 | 169 | 6/30/2026 |
| 0.7.4 | 146 | 6/29/2026 |
| 0.7.3 | 165 | 3/15/2026 |
| 0.7.1 | 141 | 3/2/2026 |
| 0.7.0 | 145 | 2/12/2026 |
| 0.6.0 | 156 | 1/11/2026 |
| 0.5.2 | 345 | 12/15/2025 |
| 0.5.1 | 265 | 12/14/2025 |
| 0.4.1 | 496 | 12/10/2025 |
| 0.4.0 | 238 | 12/5/2025 |
| 0.3.3 | 289 | 2/21/2025 |
| 0.3.2 | 247 | 1/22/2025 |
| 0.3.1 | 220 | 1/19/2025 |
| 0.3.0 | 220 | 1/13/2025 |