cad-todo-api-ef

Migrate an ASP.NET Core todo API from in-memory storage to SQLite using Entity Framework Core.

2|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/jay-steenbergen/MSSAMentorAgent --skill cad-todo-api-ef-jay-steenbergen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cad-todo-api-ef
Source: https://github.com/jay-steenbergen/MSSAMentorAgent/tree/main/.github/skills/tracks/cloud-app-dev/cad-todo-api-ef
Command: npx skills add https://github.com/jay-steenbergen/MSSAMentorAgent --skill cad-todo-api-ef-jay-steenbergen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Learners who built a basic ASP.NET Core todo API with an in-memory store lose all data on every restart and have never touched a real database, ORM, or migration workflow. This Skill guides a mentor-led, five-phase build that swaps the in-memory TodoStore for Entity Framework Core with SQLite so data persists across restarts. ## Core Features & Use Cases - DbContext and DI setup: Install EF Core SQLite packages, create a TodoDbContext, and register it with scoped lifetime, contrasting it with the previous singleton registration. - Real async/await and LINQ-to-EF: Rewrite controller endpoints to use ToListAsync, FindAsync, and SaveChangesAsync, explaining change tracking and batching. - Code-first migrations: Generate and apply an InitialCreate migration, then evolve the schema with a second migration that adds a nullable Description column without losing data. - Use Case: A learner finishes the cad-todo-api project and wants to learn ORMs hands-on; the mentor follows this recipe to add EF Core, run dotnet ef migrations, and prove persistence by restarting the app and seeing the data survive. ## Quick Start Ask the mentor to start the cad-todo-api-ef project to convert my existing todo API to use Entity Framework Core with a SQLite database.

Frequently Asked Questions about cad-todo-api-ef

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

FAQPage Schema
How do I add Entity Framework Core to an ASP.NET Core API?

Install the Microsoft.EntityFrameworkCore.Sqlite and Microsoft.EntityFrameworkCore.Design NuGet packages, create a DbContext class exposing a DbSet for your entity, and register it in Program.cs with builder.Services.AddDbContext using a SQLite connection string.

How do EF Core migrations work in .NET?

Run dotnet ef migrations add to generate a versioned migration file describing the schema change, then dotnet ef database update to apply it. The migration file contains Up and Down methods for applying and rolling back the change.

What is the difference between AddDbContext and AddSingleton in DI?

AddDbContext registers the DbContext with scoped lifetime, creating one instance per HTTP request that is then disposed. AddSingleton creates one instance for the application's lifetime, which is wrong for database contexts because connections are expensive to hold open.

Why does dotnet ef fail with 'Unable to create a DbContext'?

The most common cause is running the command from the wrong folder; you must be in the project directory containing the .csproj file. Also verify that AddDbContext actually executes in Program.cs and that the dotnet-ef global tool is installed.

Why does adding a non-nullable column migration fail on existing data?

Existing rows have no value for the new column, so a NOT NULL constraint cannot be satisfied. Make the property nullable (for example string?) so the generated migration succeeds against rows already in the database.