Nautilus.DataProvider.Sqlite
1.0.0-alpha
dotnet add package Nautilus.DataProvider.Sqlite --version 1.0.0-alpha
NuGet\Install-Package Nautilus.DataProvider.Sqlite -Version 1.0.0-alpha
<PackageReference Include="Nautilus.DataProvider.Sqlite" Version="1.0.0-alpha" />
<PackageVersion Include="Nautilus.DataProvider.Sqlite" Version="1.0.0-alpha" />
<PackageReference Include="Nautilus.DataProvider.Sqlite" />
paket add Nautilus.DataProvider.Sqlite --version 1.0.0-alpha
#r "nuget: Nautilus.DataProvider.Sqlite, 1.0.0-alpha"
#:package Nautilus.DataProvider.Sqlite@1.0.0-alpha
#addin nuget:?package=Nautilus.DataProvider.Sqlite&version=1.0.0-alpha&prerelease
#tool nuget:?package=Nautilus.DataProvider.Sqlite&version=1.0.0-alpha&prerelease
Nautilus.DataProvider.Sqlite
A SQLite data provider for the Nautilus ecosystem. It implements DataProviderBase from Nautilus.Base and adds SQLite-specific migrations, type mapping, CRUD operations, bulk insert, and metadata queries.
Features
- CRUD operations with sync and async variants.
- Filtered queries, pagination with
LIMITandOFFSET, and record counts. - Bulk insert in one transaction.
- Migrations with primary keys, composite keys,
AUTOINCREMENT, defaults, foreign keys with cascade, andIF NOT EXISTS. - Identifier validation and double-quote quoting.
[Table],[Column],[Ignore],[PrimaryKey],[AutoIncrement],[NotNull],[Default],[ConstraintDefault], and[ConstraintReferenceForeignKey].- File databases and named shared in-memory databases.
PRAGMA foreign_keys=ONand a 30-second busy timeout on every connection.
Installation
dotnet add package Nautilus.DataProvider.Sqlite
The package targets net10.0 and depends on Nautilus.Base 0.0.11-preview and Microsoft.Data.Sqlite 10.0.13.
Quick start
using Nautilus.Base.Data;
using Nautilus.Base.Data.Attributes;
using Nautilus.Base.Data.Provider;
using Nautilus.DataProvider.Sqlite;
[Table("widgets")]
public class Widget
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[NotNull, NVarchar(100)]
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
}
using var database = new SqliteDatabase(
"main",
"Data Source=app.db;Pooling=False");
var migrator = new SqliteMigrator(
DbProviderType.Sqlite,
database.CreateConnection,
database.CreateDatabase);
migrator.AddTable<Widget>().Run();
var widget = new Widget { Name = "Hammer", Price = 12.50m };
var id = database.Save(widget);
widget.Price = 13.00m;
database.Update(widget);
var loaded = database.Get<Widget>(widget.Id);
var all = database.GetAll<Widget>().ToList();
var page = database.ExecuteQuery<Widget>(new PaginationOptions(1, 20));
database.Delete<Widget>(widget.Id);
Storage convention
SQLite uses dynamic typing. The provider uses the official Microsoft.Data.Sqlite type mapping. Column types are only INTEGER, REAL, TEXT, and BLOB.
| .NET type | Column type | Stored value |
|---|---|---|
bool |
INTEGER |
0 or 1 |
| Integer types | INTEGER |
64-bit integer |
ulong |
INTEGER |
Throws above long.MaxValue |
float, double |
REAL |
IEEE 754 |
decimal |
TEXT |
0.0########################### |
string |
TEXT |
UTF-8 |
char |
TEXT |
One character |
byte[] |
BLOB |
Raw bytes |
Guid |
TEXT |
Uppercase D format |
DateTime |
TEXT |
UTC, yyyy-MM-dd HH:mm:ss.FFFFFFF |
DateTimeOffset |
TEXT |
yyyy-MM-dd HH:mm:ss.FFFFFFFzzz |
DateOnly |
TEXT |
yyyy-MM-dd |
TimeOnly |
TEXT |
HH:mm:ss.fffffff |
TimeSpan |
TEXT |
d.hh:mm:ss.fffffff |
| Enums | INTEGER |
Numeric value |
DateTime values are converted to UTC before they are written. The read converter returns DateTimeKind.Utc. The stored text has no Z suffix. DateTimeOffset keeps its offset. SQL ordering on DateTimeOffset compares local times, not instants.
decimal values are stored as text so they keep exact precision. SQL SUM, AVG, and ORDER BY on a decimal column need CAST(value AS REAL) or application-side math.
The full official mapping is at https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/types.
In-memory databases
SQLite in-memory databases need a named shared cache. This provider rejects Data Source=:memory: because each connection would open a separate database.
Use this connection string:
var name = $"app-{Guid.NewGuid():N}";
using var database = new SqliteDatabase(
"main",
$"Data Source={name};Mode=Memory;Cache=Shared");
The provider keeps one master connection open so the database survives between operations.
Migrations
var migrator = new SqliteMigrator(
DbProviderType.Sqlite,
database.CreateConnection,
database.CreateDatabase);
migrator
.AddTable<Author>()
.AddTable<Book>()
.Run();
The migrator:
- Creates tables in foreign key dependency order.
- Detects circular foreign key dependencies.
- Adds primary keys, composite keys,
AUTOINCREMENT,NOT NULL, defaults, and foreign keys withON DELETE CASCADEandON UPDATE CASCADE. - Uses
CREATE TABLE IF NOT EXISTSand skips tables that already exist. - Honors
[Table],[Column],[Ignore],[PrimaryKey],[AutoIncrement],[NotNull],[Default],[ConstraintDefault], and[ConstraintReferenceForeignKey].
[Default] and [ConstraintDefault] values are raw SQL. Quote string values yourself, for example [Default("'none'")].
SQLite has no schemas. The Schema value on [Table] is ignored.
Limitations
- Stored procedures are not supported. SQLite has no stored procedures.
- Schemas are not supported. Use attached databases instead.
- Composite primary keys work in migrations and
Save.Update,Getby key, andDeleteby key require a single primary key. - SQLite allows one writer at a time. The provider sets a 30-second busy timeout.
- SQLite does not enforce column length or precision facets. The provider validates
[NVarchar]length inSaveandSaveAsync. SaveBulkuses one transaction. It is not a native bulk copy.
Tests
The repository has two test projects:
Nautilus.DataProvider.Sqlite.UnitTestNautilus.DataProvider.Sqlite.IntegrationTest
The integration tests use temporary SQLite files and named shared in-memory databases. They do not need Docker or Testcontainers.
Analysis
The feature parity analysis and the remaining gaps are in docs/sqlite-parity-analysis.md.
License
Business Source License 1.1. The Change Date is December 31, 2028. The Change License is MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.Data.Sqlite (>= 10.0.13)
- Nautilus.Base (>= 0.0.11-preview)
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 |
|---|---|---|
| 1.0.0-alpha | 53 | 10/23/2026 |
| 0.0.2-preview | 293 | 2/12/2023 |
| 0.0.1-preview | 241 | 2/12/2023 |