Mockapala.Export.SqlLite 0.1.0-alpha.2

This is a prerelease version of Mockapala.Export.SqlLite.
dotnet add package Mockapala.Export.SqlLite --version 0.1.0-alpha.2
                    
NuGet\Install-Package Mockapala.Export.SqlLite -Version 0.1.0-alpha.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mockapala.Export.SqlLite" Version="0.1.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mockapala.Export.SqlLite" Version="0.1.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="Mockapala.Export.SqlLite" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mockapala.Export.SqlLite --version 0.1.0-alpha.2
                    
#r "nuget: Mockapala.Export.SqlLite, 0.1.0-alpha.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mockapala.Export.SqlLite@0.1.0-alpha.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mockapala.Export.SqlLite&version=0.1.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Mockapala.Export.SqlLite&version=0.1.0-alpha.2&prerelease
                    
Install as a Cake Tool

<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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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