Skip to content

a-ia/TodoApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo API with Entity Framework Core

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.

Features

  • Full CRUD operations for todo items
  • Entity Framework Core with SQL Server
  • RESTful API design
  • Swagger/OpenAPI
  • Database migrations
  • Async/await pattern throughout

Tech Stack

  • Backend: ASP.NET Core 6+ Web API
  • Database: SQL Server (LocalDB for development)
  • ORM: Entity Framework Core
  • Documentation: Swagger UI
  • Language: C#

Getting Started

Prerequisites

  • .NET 6 SDK or later
  • Visual Studio 2022 or VS Code
  • SQL Server LocalDB (comes with Visual Studio)

Installation

  1. Clone the repository
git clone https://github.com/yourusername/TodoApi.git
cd TodoApi
  1. 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
  1. Create and run database migrations
Add-Migration InitialCreate
Update-Database
  1. Run the application

Swagger Documentation

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

API Endpoints

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

Sample Request Body (POST/PUT)

{
  "name": "Learn Entity Framework Core",
  "isComplete": true
}

Database Schema

The TodoItem model includes:

  • Id (int, auto-generated primary key)
  • Name (string, the todo description)
  • IsComplete (bool, completion status)

Viewing Data inside SQL Server Object Explorer

  1. Expand (localdb)\MSSQLLocalDB -> Databases.
  2. Find TodoDb -> Expand Tables -> dbo.Todos.
  3. Right-click -> View Data to see all rows.

What I Learned

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

License

This demo project is open source and available under the MIT License.

Releases

No releases published

Packages

No packages published

Languages