liveBook · Manning

SQLite-net

As explained in .NET MAUI in Action

SQLite-net is a .NET library that provides SQLite database access and object-relational mapping for application types.

SQLite-net provides SQLite access for .NET MAUI apps through an object-relational mapper (ORM). Define persistent data as familiar C# plain-old CLR objects (POCOs), then use the library to create and work with database tables rather than manually mapping every field. section 3.3

Persist a to-do list

A MauiTodo app models each task with a TodoItem containing an Id, title, due date, and completion flag. Add the sqlite-net-pcl and sqlite-net-sqlcipher NuGet packages, store the database in the app data directory, and use a SQLiteAsyncConnection for database work. Mark the Id as a primary key with auto-increment behavior; SQLite-net can then verify that the TodoItem table exists and create it asynchronously when needed. section 3.3

Use SQLite-net when an app needs to:

  • Persist structured application data between launches in a local SQLite database. section 3.3
  • Map C# POCOs such as TodoItem to tables through ORM support. section 3.3
  • Combine local storage with SQLCipher encryption, keeping the database key in SecureStorage. section 3.3
Figure 3.10 The MauiTodo app will use SQLite to store data. The data will be encrypted using SQLCipher. The database encryption key will be a GUID, which itself will be encrypted and stored by the OS and accessed with the .NET MAUI SecureStorage API.

The architecture separates data storage, database encryption, and OS-managed protection of the encryption key. section 3.3

How .NET MAUI in Action covers it

How deep it goes
Demonstrates package setup, POCO mapping, connection setup, and asynchronous table creation without detailing SQLite internals.
Examples
Uses a MauiTodo app and a TodoItem model with identifier, title, due date, and completion state.
What it assumes
Introduces database persistence through a blank .NET MAUI project and familiar C# POCOs.
What you can do after
Apply it via SQLite-net packages to persist POCO-based app data and create tables asynchronously.
How it connects
Connects SQLite-net with SQLite, SQLCipher, SecureStorage, NuGet, POCOs, and SQLiteAsyncConnection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.