A modern .NET 8 REST API workshop designed for learning Clean Architecture principles with GitHub Copilot assistance.
# Navigate to source directory
cd dotnet/src
# Restore packages and run
dotnet restore
dotnet runVisit: http://localhost:5025/api/hello-world to test the API!
Available endpoints:
http://localhost:5025/api/hello-world- Hello World test endpointhttp://localhost:5025/swagger- API documentation
- ✅ .NET 8 SDK installed
- ✅ Visual Studio Code with C# Dev Kit extension
- ✅ GitHub Copilot extension enabled
- ✅ PostgreSQL (for future phases)
- ✅ Docker (for Testcontainers)
- ✅ Git for version control
- Overview: Introduction to the ToDo List application.
- Project Goals: Discuss the objectives and functionality.
TaskController: Implement TaskController with injected ITaskService.
Prompt examples:
We are going to create simple ToDo list application. Do not! provide any suggestions at this point. It just for context.
We are going to implement it step by step starting with TaskController. Just wait for my next prompts.
Create TaskController with injected ITaskService as interface in ASP.NET Core as Controller for CRUD operations for ToDo application.
Provide only empty bodies without implementations. Handle proper operations via suitable Http methods
Create Method: Step-by-step guide to implementing the Create method.
Create "Create" method using ITaskService. It takes object named CreateTaskCommand as parameter. Returned type should be TaskQuery.
Get Method: Step-by-step guide to implementing the Get method.
Create "Get" method using ITaskService. It takes TaskId as long as parameter. Returned type should be TaskQuery.
Update Method: Step-by-step guide to implementing the Update method.
Create "Update" method using ITaskService. It takes object named UpdateTaskCommand as parameter. Returned type should be TaskQuery.
Delete Method: Step-by-step guide to implementing the Delete method.
Create "Delete" method using ITaskService. It takes TaskId as long as parameter. This method should be 'void'.
TaskServiceAdapter: Implement TaskServiceAdapter with dependency injection.
Prompt example:
Based on TaskController provide proper implementation for interface ITaskService as TaskServiceAdapter. It should be registered for DI.
TaskEntity: Define with relevant C# attributes and EF Core configuration.
Create TaskEntity with all relevant C# attributes for storing EF Core entity. Use table name as "t_task".
Provide all relevant columns as string: "Name", TaskStatus (enum): "Status". Add proper data types for each column.
TaskRepository: Implement TaskRepository extending IRepository<TaskEntity> or using EF Core DbContext.
Create TaskRepository, which extends IRepository based on TaskEntity or uses EF Core DbContext.
TaskService: Use TaskRepository and implement CRUD operations.
In TaskService use injected TaskRepository to implement CRUD operations.
Exercise: Implement the GetAllTasks method in both TaskController and ITaskService.
Create new method in both TaskController and ITaskService for "GetAllTasks".
It will be "GET" operation and should return List<TaskQuery>.
Optional: If needed, checkout proper project version at this point:
git checkout https://github.com/vmplacademy/ai-workshop.git/dotnet/task-1TaskServiceTests: Create unit tests with mock operations and input validation.
Create TaskServiceTests, which should be unit test class based on TaskService. Provide test methods for each operation.
Handle proper input validation. Mock operations with TaskRepository.
Review and Refine: Evaluate generated test cases for accuracy.
TaskControllerApiTests: Implement using WebApplicationFactory and HttpClient.
Create TaskApiTests, which should be integration test class based on TaskController. Provide test methods for each operation.
Use WebApplicationFactory and HttpClient. Use Testcontainers for PostgreSQL.
Extend TestContainer Configuration: Ensure comprehensive integration testing.
Exercise: Implement TaskRepositoryTests for handling database interaction.
Create new test class for TaskRepository. It should contain unit test cases for handling database interaction.
It should use EF Core InMemory or Testcontainers for tests.
Optional: If needed, checkout proper project version at this point:
git checkout https://github.com/vmplacademy/ai-workshop.git/dotnet/task-2Improve Code Quality: Refactor LegacyNotificationService and entire legacy code for better readability and performance.
Prompt examples:
Explain in detail the role of the given class based on TaskOutOfDateService class.
Provide potential code improvements for <method_name>. Use C# best practices as of .NET 8. Make sure that the suggestions given improve code quality and readability.
Use Best Practices: Ensure refactored code aligns with .NET 8 standards.
XML Docs: Automatically generate for TaskController and ITaskService.
README.md: Create comprehensive project documentation using GitHub Copilot.
Prompt examples:
Create simple project documentation as README.md based on already existing XML documentation in TaskController.
Add information about used technologies such as ASP.NET Core 9.x, PostgreSQL, Testcontainers.
Provide different sections with proper headers as "Main project goal", "Used technologies", "How to start it?".
Use markdown format.
Provide suggestions what could be also included in such a README.md?
dotnet/
├── 📄 README.md # This complete guide
├── 🚫 .gitignore # .NET-specific gitignore
└── 📁 src/ # All source code
├── 📦 TodoApp.csproj # Project with all NuGet packages
├── ⚙️ Program.cs # Application entry point
├── ⚙️ appsettings.json # Configuration
├── 📁 Controllers/ # API Controllers
│ └── HelloWorldController.cs # Test controller (✅ Phase 1)
├── 📁 Dtos/ # Data Transfer Objects (Phase 2)
└── 📁 Domains/ # Domain logic (Phase 2)
├── 📁 Models/ # Entities
├── 📁 Services/ # Business logic
└── 📁 Data/ # Data access
Our project comes with production-ready packages:
Microsoft.AspNetCore.OpenApi- OpenAPI/Swagger supportSwashbuckle.AspNetCore- Swagger UI
Microsoft.EntityFrameworkCore- Core EF functionalityMicrosoft.EntityFrameworkCore.Design- Design-time toolsMicrosoft.EntityFrameworkCore.Tools- Package Manager Console toolsNpgsql.EntityFrameworkCore.PostgreSQL- PostgreSQL provider
Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCoreAspNetCore.HealthChecks.Npgsql
FluentValidation.AspNetCore- Input validationAutoMapper+AutoMapper.Extensions.Microsoft.DependencyInjection
Serilog.AspNetCore- Structured loggingSerilog.Sinks.Console+Serilog.Sinks.File
Microsoft.AspNetCore.Mvc.Testing- Integration testingTestcontainers.PostgreSql- Database testing with containersMicrosoft.EntityFrameworkCore.InMemory- In-memory testing
# Build the project
dotnet build
# Run the application
dotnet run
# Run with watch (auto-reload)
dotnet watch run
# Clean build artifacts
dotnet clean
# Restore NuGet packages
dotnet restoreThis project follows Clean Architecture principles:
- Controllers - Handle HTTP requests and responses
- DTOs - Data transfer objects for API boundaries
- Domain Models - Core business entities
- Services - Business logic implementation
- Data Layer - Repository pattern with Entity Framework
Coming next in the workshop:
- 📝 Task Entity and TaskController
- 🗄️ PostgreSQL integration with Entity Framework Core
- ✅ CRUD operations for Todo items
- 🧪 Unit and Integration Tests with Testcontainers
- 🏗️ Clean Architecture implementation
- 📊 Health Checks and Monitoring
This project is optimized for GitHub Copilot assistance:
- Use descriptive comments to guide Copilot suggestions
- Follow consistent naming conventions
- Leverage the rich context from NuGet packages
- Ask Copilot to implement patterns like Repository or Service layers
You now have a fully functional .NET 8 Web API with:
- ✅ Controller-based architecture
- ✅ OpenAPI/Swagger documentation
- ✅ All necessary NuGet packages
- ✅ Clean project structure
- ✅ Ready for Phase 2 development
Next step: Ready to implement the TodoList functionality!
- Set up ASP.NET Core REST API with HelloWorld controller
- Clean project structure for future expansion
- Integrate GitHub Copilot in your IDE
- Define Task entity and DTOs (C# 13 record types)
- Create controller endpoints for CRUD operations (empty bodies at first)
- Add request validation (FluentValidation/DataAnnotations)
- Integrate PostgreSQL using Entity Framework Core
- Set up EF Core migrations for schema management
- Implement repository interfaces for data access
- Implement service layer for business rules
- Add validation and error handling
- Use Copilot to suggest/refactor business logic
- Write unit tests with xUnit and Moq
- Add integration tests using Testcontainers for PostgreSQL
- Ensure all layers are covered by tests
- .NET 8 - Latest LTS version
- ASP.NET Core - Web API framework
- C# 13 - Modern language features
- PostgreSQL - Primary database
- Entity Framework Core 9 - ORM
- Testcontainers - Testing infrastructure
- OpenAPI/Swagger - API documentation
- Serilog - Structured logging
- FluentValidation - Request validation
- AutoMapper - Object mapping
- GitHub Copilot - AI-assisted development
This workshop is designed to work seamlessly with GitHub Copilot:
- 🧠 Clear patterns that Copilot understands
- 📝 Well-documented code for better suggestions
- 🏗️ Consistent structure for predictable completions
- 🧪 Testing patterns that Copilot can extend
- Start with simple hello-world endpoint
- Gradually add layers of complexity
- Each phase builds on previous knowledge
- Real-world patterns and practices
- ✅ .NET 8 SDK - Latest .NET version
- ✅ Visual Studio Code - Primary IDE for this workshop
- ✅ PostgreSQL (for later phases)
- ✅ Docker (for Testcontainers)
🎯 C# Dev Kit - ms-dotnettools.csdevkit
- Complete C# development experience in VS Code
- Includes IntelliSense, debugging, and project management
- Built on the same foundation as Visual Studio
- Installation: C# Dev Kit
The C# Dev Kit automatically includes:
- C# Extension (
ms-dotnettools.csharp) - Base language services - IntelliCode for C# Dev Kit (optional) - AI-powered development experience
🤖 GitHub Copilot - GitHub.copilot
- AI-powered code completions and suggestions
- Essential for this workshop
- Installation: GitHub Copilot
💬 GitHub Copilot Chat - GitHub.copilot-chat
- Interactive AI assistance and code explanations
- Installation: GitHub Copilot Chat
If you prefer to install everything at once:
📦 .NET Extension Pack - ms-dotnettools.vscode-dotnet-pack
- Includes C# Dev Kit + additional tools
- Installation: .NET Extension Pack
# Install essential extensions via command line
code --install-extension ms-dotnettools.csdevkit
code --install-extension GitHub.copilot
code --install-extension GitHub.copilot-chat
# OR install the complete pack
code --install-extension ms-dotnettools.vscode-dotnet-packAfter installing extensions, verify your setup:
# Check .NET SDK version
dotnet --version
# Verify VS Code can find .NET
dotnet --infoExpected output: .NET version should show 9.0.x or later
API won't start?
cd dotnet/src
dotnet clean
dotnet restore
dotnet build
dotnet runPort 5025 in use?
lsof -ti:5025 | xargs kill -9HTTPS redirect warning? This is normal in development mode - the warning is disabled for local development.
C# IntelliSense not working?
- Ensure C# Dev Kit extension is installed and enabled
- Reload VS Code window:
Ctrl+Shift+P→ "Developer: Reload Window" - Check VS Code status bar for .NET SDK version
Missing "Required assets to build and debug"?
- When VS Code asks to add required assets, click "Yes"
- This creates
.vscode/launch.jsonand.vscode/tasks.json
GitHub Copilot not working?
- Verify you have an active GitHub Copilot subscription
- Sign in to GitHub in VS Code:
Ctrl+Shift+P→ "GitHub: Sign In" - Check Copilot status in VS Code status bar
Project not loading in VS Code?
- Open the
dotnet/srcfolder (containingTodoApp.csproj) - VS Code should show "Restore" notification - click it
- Wait for OmniSharp to finish loading (status bar indicator)
- 🔗 .NET 8 Documentation
- 🔗 ASP.NET Core Minimal APIs
- 🔗 Entity Framework Core
- 🔗 GitHub Copilot Best Practices
- 🔗 Clean Architecture in .NET
This is a workshop project designed for learning. Feel free to:
- 🐛 Report issues
- 💡 Suggest improvements
- 🚀 Add new features
- 📚 Enhance documentation
MIT License - see LICENSE file for details.
Happy Coding with GitHub Copilot! 🚀🤖