Metadata with SQLite and EF Core
How SQLite and EF Core track document lifecycle, progress, and ingestion state.
The document lifecycle states
public enum DocumentStatus
{
Pending,
Processing,
Indexed,
Failed
}RAG.Core/Data/DocumentRecord.cs stores document metadata:
- document ID;
- filename and content type;
- object-storage key;
- ingestion status;
- error message;
- final chunk count;
- progress stage and percentage;
- processed and total chunks;
- timestamps.
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.