maui-sqlite-database

Integrate a SQLite database with sqlite-net-pcl for offline persistence in .NET MAUI apps.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/snailb1007/snail-codex-skills --skill maui-sqlite-database-snailb1007
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: maui-sqlite-database
Source: https://github.com/snailb1007/snail-codex-skills/tree/main/skills/maui-sqlite-database
Command: npx skills add https://github.com/snailb1007/snail-codex-skills --skill maui-sqlite-database-snailb1007

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a SQLite-backed local database for .NET MAUI apps using sqlite-net-pcl to enable offline data persistence, lightweight data modeling, and a lazy-initialized database service.

Core Features & Use Cases

  • Async, lazy-initialized DatabaseService with a single shared SQLite connection
  • WAL mode enabled to improve concurrency between readers and writers
  • Data models annotated with ORM attributes for straightforward mapping
  • DI-registration of the database service for use across MVVM and other UI patterns
  • Cross-platform database path using FileSystem.AppDataDirectory for reliability

Quick Start

Register the DatabaseService as a singleton in MauiProgram and start using it to persist and retrieve data.

Frequently Asked Questions about maui-sqlite-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up SQLite local storage in a .NET MAUI app?▼

SQLite offline storage in .NET MAUI is set up by registering a lazily initialized DatabaseService as a singleton in MauiProgram. It uses a shared SQLiteAsyncConnection and FileSystem.AppDataDirectory to enable offline data persistence across your app.

What is the best way to handle concurrent database reads and writes in MAUI?▼

Concurrent database reads and writes in MAUI are handled by enabling WAL mode on your SQLite database. WAL (Write-Ahead Logging) improves concurrency between readers and writers using your single shared SQLiteAsyncConnection.

How do I map data models to SQLite tables in MAUI?▼

Mapping data models to SQLite tables in MAUI is done by annotating your classes with ORM attributes provided by sqlite-net-pcl. This approach allows the DatabaseService to automatically create tables and execute CRUD operations.

Does sqlite-net-pcl work with dependency injection in MAUI MVVM apps?▼

Yes, sqlite-net-pcl works with dependency injection in MAUI MVVM apps. You register the database service as a singleton, allowing the lazily initialized SQLiteAsyncConnection to be injected directly into your view models.

Where should I store the SQLite database file for cross-platform MAUI apps?▼

For cross-platform MAUI apps, the SQLite database file should be stored in FileSystem.AppDataDirectory. This ensures a reliable, platform-specific local path for offline data persistence across mobile devices.

Why use a lazy-initialized SQLiteAsyncConnection in MAUI?▼

A lazy-initialized SQLiteAsyncConnection in MAUI delays database connection creation until first use. This singleton pattern ensures a single shared connection, optimizing resource usage for local offline CRUD operations.