maui-sqlite-database

Configure SQLite storage for .NET MAUI apps with sqlite-net-pcl.

Updated Nov 27, 2025
One-click install
npx skills add https://github.com/seydakaratekeli/KamPay3 --skill maui-sqlite-database-seydakaratekeli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-sqlite-database
Source: https://github.com/seydakaratekeli/KamPay3/tree/main/KamPay/.github/skills/maui-sqlite-database%20-%20Kopyala
Command: npx skills add https://github.com/seydakaratekeli/KamPay3 --skill maui-sqlite-database-seydakaratekeli

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Adds a robust, cross-platform local SQLite persistence layer to .NET MAUI applications, removing common pitfalls like wrong package choices, unsafe file paths, multiple connection instances, and data corruption from file operations or missing WAL mode.

Core Features & Use Cases

  • Correct package guidance: recommends sqlite-net-pcl and the SQLitePCLRaw bundle to avoid incompatible libraries.
  • Singleton async database service: lazy-initialized SQLiteAsyncConnection with DI singleton registration to prevent concurrency issues and data corruption.
  • WAL and performance patterns: enables WAL mode, advises transactions for batch writes, indexing, and raw SQL for complex queries to improve concurrency and speed.
  • File and platform handling: uses FileSystem.AppDataDirectory for cross-platform paths, notes iOS iCloud considerations, and requires closing the connection before file moves, deletes, or backups.
  • Use cases: offline data persistence for MAUI mobile apps, local CRUD storage for MVVM or C# markup projects, and reliable local caches for intermittent-network scenarios.

Quick Start

Register a singleton DatabaseService that lazily creates a single SQLiteAsyncConnection using sqlite-net-pcl, enable WAL, call CreateTableAsync for your models, and use FileSystem.AppDataDirectory for the database file path.

Frequently Asked Questions about maui-sqlite-database

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

FAQPage Schema
What's the best way to set up a local SQLite database in .NET MAUI?

The best way to set up local SQLite in .NET MAUI is using sqlite-net-pcl with a lazy async singleton SQLiteAsyncConnection. Register this DatabaseService via dependency injection as a singleton to prevent concurrency issues and data corruption.

How do I handle concurrent reads and writes in a MAUI SQLite database?

To handle concurrent reads and writes in a MAUI SQLite database, enable WAL mode on your SQLiteAsyncConnection. Additionally, use transactions for batch writes and apply indexing to improve concurrency and speed during database operations.

Where should I store the SQLite database file in a .NET MAUI app?

You should store the SQLite database file in the cross-platform FileSystem.AppDataDirectory. This ensures reliable local storage across mobile and desktop MAUI apps, while also noting specific iOS iCloud considerations for backups.

Why does my SQLite database get corrupted during file backups or moves in MAUI?

SQLite database corruption during file operations in MAUI occurs when the connection remains open. You must close the SQLiteAsyncConnection before executing any file moves, deletes, or backups to prevent data loss.

Do I need sqlite-net-pcl for local offline persistence in .NET MAUI?

Yes, you need sqlite-net-pcl and the SQLitePCLRaw bundle for local offline persistence in .NET MAUI. These packages provide the correct async singleton connection patterns required to avoid incompatible libraries and ensure safe cross-platform data storage.

Can I use raw SQL queries with SQLiteAsyncConnection in MAUI?

Yes, you can use raw SQL queries with SQLiteAsyncConnection in MAUI for complex data retrieval. Combining raw SQL with indexing and transactions for batch writes provides optimal performance for local CRUD storage and intermittent-network caching.