SqliteInit 1.0.0

dotnet add package SqliteInit --version 1.0.0
                    
NuGet\Install-Package SqliteInit -Version 1.0.0
                    
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="SqliteInit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqliteInit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SqliteInit" />
                    
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 SqliteInit --version 1.0.0
                    
#r "nuget: SqliteInit, 1.0.0"
                    
#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 SqliteInit@1.0.0
                    
#: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=SqliteInit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SqliteInit&version=1.0.0
                    
Install as a Cake Tool

SqliteInit

Manage Sqlite schema migrations with a simple folder structure. One dependency on Microsoft.Data.Sqlite.

Folders that start with numbers are schema versions.

Files within that folder that start with numbers will be executed as SQL sequentially (sorted by number ascending). File extension is not considered.

Folders/Files that do not start with numbers will be skipped. In other words, we only include it if it starts with ^\d+

In your app startup code, call SqliteInit.Init(), passing in the connection or connection string and path to your migrations code. After applying migrations, it will automatically update PRAGMA user_version to match the number of the folder. Future migrations check the version number against the migrations folder numbers and upgade if required.

SqliteInit has good error handling and logging. To log, pass in an optional func. Note that, to avoid taking a dependency on Microsoft.Extensions.Logging, you must cast from SqliteInit.LogLevel to Microsoft.Extensions.Logging.LogLevel. If your host application is not using ILogger, then you may do what you wish with LogLevel in your func.

var logger = app.Services.GetRequiredService<ILogger<Program>>();
SqliteInit.SqliteInit.Init(connectionString, schemaDir, (ll, s) => logger.Log((LogLevel)ll, s) );

Example folder structure:

-- 📂 Migrations
  -- 📂 001 Initial Tables
    -- 📄 001 Create Tables.sql
    -- 📄 002 Create Indexes.sql
    -- 📄 003 Insert Test Data.sql
  -- 📂 002 Alter Schema
    -- 📄 README.md # File ignored, does not start with digits
    -- 📄 001 Alter Schema.sql
  -- 📂 WIP Version 3 # Folder ignored, does not start with digits
    -- 📄 001 draft.sql # Ignored 

FAQ:

  • Why is this limited to Sqlite and not other databases? Current version is stored in a Sqlite-specific feature, PRAGMA user_version. While it would be straightforward to add a user-version table and keep track there, I've never had a need to do it.
Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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
1.0.0 290 11/13/2025
0.9.1 276 11/12/2025
0.9.0 242 12/27/2023