You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4252287
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+76-28Lines changed: 76 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# NuExt.System.Data.SQLite
2
2
3
-
`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.
3
+
`NuExt.System.Data.SQLite`is a high-performance ADO.NET infrastructure layer for SQLite-based .NET desktop, hybrid, and modular applications. It extends `System.Data.SQLite` with process-local connection synchronization, explicit transaction and database context management, lightweight DAL infrastructure, and transactional migrations with validated history tracking.
-**Transaction Scope Management**: Provides explicit transaction state tracking, prevents nested transactions, preserves original exceptions when rollback fails, and supports coordinated execution through reentrant connection locks.
-**ADO.NET Utilities**: Provides helpers for commands, parameters, readers, data adapters, schema inspection, and common SQLite operations.
17
-
-**Allocation-Conscious APIs**: Provides span-based parameters, `ValueTask`-based coordination, and explicit-state callbacks that help avoid closure allocations.
18
-
-**Database Migrations**: Applies schema and data migrations transactionally, supports independent scopes and cross-scope dependencies, preserves global application order, and strictly validates each migration sequence.
17
+
-**Allocation-Conscious APIs**: Uses span-based parameters, `ValueTask`-based coordination, pooling, and explicit callback state in performance-sensitive paths.
18
+
-**Database Migrations**: Applies schema and data migrations transactionally, supports independent scopes and cross-scope dependencies, records the resulting application order, and strictly validates each migration sequence.
19
19
20
20
## Why NuExt.System.Data.SQLite?
21
21
22
-
`NuExt.System.Data.SQLite` is designed as a performance-oriented infrastructure layer over ADO.NET rather than an ORM. It keeps SQL, commands, parameters, readers, and transactions explicit while removing repetitive connection, transaction, and resource lifecycle code. It also preserves SQLite's synchronous execution model instead of wrapping database operations in artificial asynchronous work.
22
+
`NuExt.System.Data.SQLite` is intended for applications that use SQLite directly through ADO.NET and need a lightweight DAL foundation, predictable transaction ownership, synchronized multi-step operations, and forward-only schema evolution without adopting an ORM.
23
23
24
-
The library supports both standalone DAL operations and coordinated units of work, protects complete database operation scopes during concurrent and reentrant execution, and provides forward-only migrations with deterministic dependency ordering, independent scopes, and strict history validation.
24
+
The library keeps SQL and ADO.NET primitives visible while centralizing repetitive infrastructure. Applications retain direct control over commands, parameters, readers, resource lifetimes, and transaction boundaries, while DAL components share a consistent execution model for standalone operations and coordinated units of work.
25
25
26
-
The result is a lightweight data access foundation that adds predictable resource ownership, transaction coordination, and schema evolution without introducing change tracking, SQL generation, or a custom query language.
26
+
Database migrations follow the same ownership, locking, and transaction rules as application data access. Independent modules can evolve their schemas separately and declare dependencies without being forced into a single global migration sequence. Strict history validation prevents incompatible migration sequences from being applied silently.
27
+
28
+
By preserving SQLite's synchronous execution model and avoiding hidden change tracking, implicit query generation, and artificial asynchronous wrappers, the library keeps execution predictable, makes performance costs visible, and allows database behavior to be understood directly from application code.
29
+
30
+
## API Overview
31
+
32
+
### Data Access and Transactions
33
+
34
+
-**`SQLiteDalBase`**: Base class for DAL implementations with provider-managed operations and caller-owned transactional contexts shared across multiple DAL components.
35
+
-**`SQLiteDbConnection`**: Provides synchronized connection access, transaction coordination, command execution, schema inspection, and common SQLite operations.
36
+
-**`SQLiteDbTransaction`**: Tracks transaction state and provides explicit commit and rollback operations.
37
+
-**`SQLiteDbContext`**: Provides a connection and transaction shared across multiple DAL components within a caller-owned or provider-managed operation.
38
+
39
+
### Database Migrations
40
+
41
+
-**`SQLiteDbMigration`**: Defines a forward-only schema or data migration.
42
+
-**`SQLiteDbMigrationContext`**: Provides command execution within a migration transaction.
43
+
-**`SQLiteDbMigrationDependency`**: Declares a dependency on a migration from another scope.
44
+
-**`SQLiteDbMigrationPlan`**: Coordinates dependent migration sequences across multiple scopes.
27
45
28
46
## Concurrency and Locking
29
47
@@ -47,6 +65,47 @@ An existing `SQLiteDbContext` can instead be shared across multiple DAL componen
Passing `null` as the database context creates a provider-managed operation that owns its connection, lock, transaction, and resource lifetime. Passing an existing `SQLiteDbContext` allows multiple DAL components to participate in the same caller-owned transaction.
Use `MigrateScope` for an independent named migration sequence. Use `SQLiteDbMigrationPlan` only when migrations from multiple scopes depend on one another.
139
-
140
-
Migrations are applied in the order in which they are registered within each scope. Each migration scope maintains an independent ordered sequence, and its applied history must be an exact prefix of the configured migration sequence.
197
+
Use `MigrateScope` when an application component owns its own migration sequence. For example, the application core and an optional video module can evolve independently without coordinating migration identifiers or sharing one global version number.
141
198
142
-
`SQLiteDbMigrationPlan`coordinates multiple scopes and automatically orders pending migrations according to their declared dependencies while preserving the configured order within each scope. The plan detects missing dependencies, unknown migrations, and dependency cycles before incompatible schema changes can be applied.
199
+
Use `SQLiteDbMigrationPlan`when one component requires schema changes introduced by another. The plan determines which migration can run next, preserves the declared order within every scope, and rolls back the complete migration batch if a required migration is missing or the dependencies cannot be resolved.
143
200
144
-
Dependencies may reference required scopes or optional scopes. An optional-scope dependency is ignored only when the scope is neither registered in the plan nor present in migration history. This prevents migrations from ignoring schema changes left by a module that was previously installed but is not currently loaded.
201
+
The applied history of each scope must match the beginning of its configured migration sequence. This prevents an application from silently continuing when migrations have been removed, reordered, or replaced after being applied.
145
202
146
-
Applied migrations are recorded in the `__nuext_migrations` table with a global history identifier, scope-local sequence, declared dependencies, application time, and optional version information. This preserves the complete migration chronology while allowing the application core and independently installed modules to maintain separate migration chains.
203
+
Optional dependencies allow a module to integrate with another module when it is installed. A dependency is ignored only when the referenced scope has never been registered or recorded, so removing a previously installed module cannot silently hide its migration history.
147
204
148
-
When a connection factory is used, the complete migration plan is executed within a synchronized transaction and is rolled back if any migration fails. A plan can also run within an existing `SQLiteDbContext`, allowing migrations and application operations to share the same caller-owned transaction.
205
+
Applied migrations are recorded in the `__nuext_migrations` table together with their scope, sequence, dependencies, application time, and optional application version.
149
206
150
-
## Commonly Used Types
151
-
152
-
-**`SQLiteDalBase`**: Base class for SQLite DAL implementations with synchronized provider-managed context execution and access to connection creation for custom scenarios.
153
-
-**`SQLiteDbConnection`**: Wraps SQLite connections with process-local synchronization, transaction coordination, command execution, schema inspection, and common data access utilities.
154
-
-**`SQLiteDbTransaction`**: Wraps SQLite transactions with explicit state tracking, commit and rollback operations, and transaction lifetime diagnostics.
155
-
-**`SQLiteDbContext`**: Manages connection state and transaction lifetime, with optional validation that the connection lock remains held for the lifetime of the context.
156
-
-**`SQLiteDbMigration`**: Base class for defining forward-only SQLite schema and data migrations within ordered, independently validated scopes.
157
-
-**`SQLiteDbMigrationDependency`**: Describes a required migration from another scope, including optional-scope dependencies.
-**`SQLiteDbMigrationContext`**: Provides the execution context used by SQLite migrations.
207
+
When a connection factory is used, the complete plan runs within one synchronized transaction. A plan can also use an existing `SQLiteDbContext` when migrations must participate in a transaction owned by the caller.
160
208
161
209
## Installation
162
210
@@ -174,21 +222,21 @@ Or via Visual Studio:
174
222
175
223
## Compatibility
176
224
177
-
**.NET Standard 2.0+, .NET 8/9/10 and .NET Framework 4.6.2+**
225
+
-**.NET Standard 2.0+, .NET 8/9/10, and .NET Framework 4.6.2+**
178
226
179
227
## Usage Examples
180
228
181
-
For examples of how to use these classes, see the [samples](samples). These samples provide practical guidance on implementing the library's features in real-world scenarios.
229
+
For examples of how to use these classes, see the [samples](https://github.com/nu-ext/NuExt.System.Data.SQLite/tree/main/samples). These samples provide practical guidance on implementing the library's features in real-world scenarios.
<Description>High-performance SQLite data access utilities for .NET, providing synchronized process-local connection access, explicit transaction management, a consistent DAL foundation, and transactional database migrations with validated history tracking.</Description>
7
+
<Description>High-performance ADO.NET infrastructure for SQLite-based .NET applications, providing synchronized process-local connection access, explicit transaction and database context management, a consistent DAL foundation, and transactional migrations with validated history tracking.</Description>
0 commit comments