Guide Home 1. Solution Topology 2. Aspire as 3. Shared Configuration 4. Metadata with 5. Upload API 6. Object Storage 7. Worker Ingestion 8. Extracting and 9. Literary Artifacts 10. AI Provider 11. Qdrant Vector 12. Ask Flow 13. Prompting and 14. Testing the 15. Local Development All Guides
Guide navigationIndex and chapters
Chapter 4

Metadata with SQLite and EF Core

How SQLite and EF Core track document lifecycle, progress, and ingestion state.

Decorative chapter image for Metadata with SQLite and EF Core
The document lifecycle states
public enum DocumentStatus
{
    Pending,
    Processing,
    Indexed,
    Failed
}

RAG.Core/Data/DocumentRecord.cs stores document metadata:

The statuses are:

Pending
Processing
Indexed
Failed

RAG.Core/Data/RagDbContext.cs maps this entity with EF Core. This is intentionally simple. SQLite is good enough for a local learning project and gives the API and worker a shared durable state.

The database initializer lives in ServiceCollectionExtensions.EnsureRagDatabaseAsync. It uses EnsureCreatedAsync and also performs lightweight idempotent column checks for the progress fields. This avoids forcing a developer to delete local data after the model changes during the tutorial.

In a production system, you would normally replace this with formal EF Core migrations.