A simple REST API for managing todo items, built with ASP.NET Core and Entity Framework Core. This project demonstrates clean architecture patterns, database integration, and modern .NET development practices.
- Full CRUD operations for todo items
- Entity Framework Core with SQL Server
- RESTful API design
- Swagger/OpenAPI
- Database migrations
- Async/await pattern throughout
- Backend: ASP.NET Core 6+ Web API
- Database: SQL Server (LocalDB for development)
- ORM: Entity Framework Core
- Documentation: Swagger UI
- Language: C#
- .NET 6 SDK or later
- Visual Studio 2022 or VS Code
- SQL Server LocalDB (comes with Visual Studio)
- Clone the repository
git clone https://github.com/yourusername/TodoApi.git
cd TodoApi
-
Install EF Core packages (if not already installed)
I installed using NuGet Package Manager Console under Tools in Visual Studio:
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
- Create and run database migrations
Add-Migration InitialCreate
Update-Database
- Run the application
Once the application is running, you can explore the API endpoints at:
https://localhost:XXXX/swagger
You can check the direct API endpoint here:
https://localhost:XXXX/api/Todo
Method | Endpoint | Description |
---|---|---|
GET | /api/todo |
Get all todo items |
GET | /api/todo/{id} |
Get a specific todo item |
POST | /api/todo |
Create a new todo item |
PUT | /api/todo/{id} |
Update an existing todo item |
DELETE | /api/todo/{id} |
Delete a todo item |
{
"name": "Learn Entity Framework Core",
"isComplete": true
}
The TodoItem model includes:
Id
(int, auto-generated primary key)Name
(string, the todo description)IsComplete
(bool, completion status)
- Expand (localdb)\MSSQLLocalDB -> Databases.
- Find TodoDb -> Expand Tables -> dbo.Todos.
- Right-click -> View Data to see all rows.
Building this API helped me understand:
- How Entity Framework Core simplifies database operations
- Implementing async patterns for better performance
- Setting up proper dependency injection in .NET
- Creating clean, testable controller logic
- Database migration strategies
This demo project is open source and available under the MIT License.