Mockapala.Export.SqlLite
0.1.0-alpha.2
dotnet add package Mockapala.Export.SqlLite --version 0.1.0-alpha.2
NuGet\Install-Package Mockapala.Export.SqlLite -Version 0.1.0-alpha.2
<PackageReference Include="Mockapala.Export.SqlLite" Version="0.1.0-alpha.2" />
<PackageVersion Include="Mockapala.Export.SqlLite" Version="0.1.0-alpha.2" />
<PackageReference Include="Mockapala.Export.SqlLite" />
paket add Mockapala.Export.SqlLite --version 0.1.0-alpha.2
#r "nuget: Mockapala.Export.SqlLite, 0.1.0-alpha.2"
#:package Mockapala.Export.SqlLite@0.1.0-alpha.2
#addin nuget:?package=Mockapala.Export.SqlLite&version=0.1.0-alpha.2&prerelease
#tool nuget:?package=Mockapala.Export.SqlLite&version=0.1.0-alpha.2&prerelease
<img align="left" src="https://raw.githubusercontent.com/Jonikyro/Mockapala/main/Images/logo_300x300.png" alt="Mockapala logo" width="90" />
Mockapala.Export.Sqlite
SQLite exporter for Mockapala. Exports generated test data into a SQLite database using parameterized INSERTs in a single transaction for fast, reliable seeding.
Usage
Export to a database file
using Mockapala.Schema;
using Mockapala.Generation;
using Mockapala.Export.Sqlite;
// 1. Define schema
var schema = SchemaCreate.Create()
.Entity<Company>(e => e.Key(c => c.Id))
.Entity<Customer>(e =>
{
e.Key(c => c.Id);
e.Relation<Company>(c => c.CompanyId);
})
.Entity<Order>(e =>
{
e.Key(o => o.Id);
e.Relation<Customer>(o => o.CustomerId);
})
.Build();
// 2. Generate data
var generator = new DataGenerator();
var data = generator.Generate(schema, cfg => cfg
.Count<Company>(5)
.Count<Customer>(50)
.Count<Order>(200)
.Seed(42));
// 3. Export to SQLite file
var exporter = new SqliteExporter();
exporter.ExportToDatabase(schema, data, "testdata.db", createIfMissing: true);
Export with a connection string
exporter.ExportToDatabase(schema, data, "Data Source=testdata.db;Mode=ReadWriteCreate");
Options
Configure the exporter via SqliteExportOptions:
var exporter = new SqliteExporter(new SqliteExportOptions
{
CreateTables = true, // Emit CREATE TABLE IF NOT EXISTS — default: true
UseWalMode = true, // Set PRAGMA journal_mode = WAL — default: true
QuoteIdentifiers = true, // Wrap identifiers in double-quotes — default: true
TableNameResolver = t => $"tbl_{t.Name}", // Custom table name mapping — default: type name
});
| Option | Default | Description |
|---|---|---|
CreateTables |
true |
Emits CREATE TABLE IF NOT EXISTS before inserting rows. Set to false if tables already exist. |
UseWalMode |
true |
Sets PRAGMA journal_mode = WAL on connection open for better write performance. |
QuoteIdentifiers |
true |
Wraps table and column names in "double quotes". |
TableNameResolver |
Type name | Func<Type, string> that maps an entity type to its destination table name. |
Table and Column Names from Schema
The exporter respects ToTable and HasColumnName metadata defined in the Mockapala schema:
var schema = SchemaCreate.Create()
.Entity<Order>(e =>
{
e.Key(o => o.Id);
e.ToTable("orders");
e.Property(o => o.CustomerId).HasColumnName("customer_id");
})
.Build();
Priority: TableNameResolver (exporter option) > ToTable (schema) > type name.
Property Conversions
The exporter respects property conversions defined in the schema. This lets you store non-scalar types or transform values at export time:
.Entity<Order>(e =>
{
e.Key(o => o.Id);
e.Property(o => o.Status).HasConversion(s => s.ToString()); // enum → TEXT
})
Type Mapping
| .NET Type | SQLite Type |
|---|---|
int, long, short, byte, bool, enums |
INTEGER |
float, double, decimal |
REAL |
byte[] |
BLOB |
string, DateTime, DateTimeOffset, TimeSpan, Guid, others |
TEXT |
| 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 (>= 9.0.2)
- Mockapala (>= 0.1.0-alpha.2)
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.1.0-alpha.2 | 92 | 2/18/2026 |