Porfolio & Blog CMS persists data with Entity Framework Core 10 backed by a SQLite database. SQLite requires no server process and no installation — the entire database is a single file (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Andrespeerez/porfolio-blog/llms.txt
Use this file to discover all available pages before exploring further.
blog.db) created automatically in the project root when migrations are applied. The connection string is read from appsettings.json and injected into AppDbContext at startup via the standard IConfiguration pipeline.
Schema
The initial migration (20260702123917_InitialCrate) creates one table: Users.
| Column | Type | Constraints |
|---|---|---|
Id | INTEGER | Primary key, AUTOINCREMENT |
Email | TEXT | NOT NULL, unique index IX_Users_Email |
PasswordHash | TEXT | NOT NULL |
Email is enforced at both the database level (via the migration) and the EF Core model level (via HasIndex(...).IsUnique()), preventing duplicate accounts even under concurrent insert scenarios.
The Id column uses SQLite’s AUTOINCREMENT keyword, meaning deleted Ids are never reused — a deliberate choice to avoid referential ambiguity if foreign keys are added in future migrations.
AppDbContext
AppDbContext is the single EF Core context for the entire application. It exposes the Users set and configures the unique email index in OnModelCreating:
Infrastructure/Persistence/Context/AppDbContext.cs
Program.cs, pointing at the SQLite connection string:
Program.cs
UserRepository receives AppDbContext through constructor injection and is the only class allowed to query it directly, keeping all database access behind the IUserRepository port:
Infrastructure/Persistence/Repositories/UserRepository.cs
Connection string
The database location is configured inappsettings.json:
appsettings.json
Data Source=blog.db is a relative path, so blog.db is created in the current working directory when the application runs — typically the project root during development and the publish output folder in production. To use an absolute path or a different location, update the value to e.g. Data Source=/var/data/blog.db.
Running migrations
Restore the dotnet-ef tool
The
dotnet-ef CLI tool is pinned in .config/dotnet-tools.json. Restore it after cloning the repository:Apply all pending migrations
Run the following command from the project root to bring the database schema up to date:EF Core reads the connection string from
appsettings.json, connects to (or creates) blog.db, and applies every migration that has not yet been recorded in the __EFMigrationsHistory table.Creating new migrations
When you add or modify a property on a Domain entity, generate a new migration to record the schema change:<MigrationName> with a descriptive PascalCase name such as AddPostsTable or AddUserDisplayName. EF Core compares the current model snapshot against the last known state and generates the appropriate Up / Down methods automatically. Always review the generated migration file before applying it to a shared or production database.