A step-by-step guide to get up and running with Project Templates, from choosing your template to deploying your first application.
- Prerequisites
- Choosing Your Template
- Setup Instructions
- Project Structure Overview
- Common Tasks
- Troubleshooting
Before you begin, ensure you have the following installed:
Git
- Download: https://git-scm.com/downloads
- Verify:
git --version
Supported Operating Systems:
- Windows 10 / 11
- macOS 10.14+
- Linux (Ubuntu, Fedora, etc.)
Required Software:
- .NET 9 SDK - Download
- Verify:
dotnet --version - Should show version 9.0.x or higher
- Verify:
Recommended
- Visual Studio 2022 Community (Free)
- Visual Studio Code with C# extension
- SQL Server Express (optional, for local development)
Coming soon
Ask yourself these questions:
-
What is your project timeline?
- Very tight (< 1 month) → Layered Architecture
- Normal (1-3 months) → Layered or Vertical Slice
- Extended timeline → Clean Architecture
-
How complex is your business logic?
- Simple (basic CRUD) → Layered
- Medium (some complex workflows) → Vertical Slice
- Complex (multiple systems integration) → Clean
-
How big will your team be?
- Solo or small (1-3 people) → Layered
- Medium (4-10 people) → Vertical Slice
- Large (> 10 people) → Clean or Vertical Slice
-
How long will this project live?
- Short-term (< 1 year) → Layered
- Medium-term (1-3 years) → Vertical Slice
- Long-term (> 3 years) → Clean
Read the ARCHITECTURE.md guide for detailed information about each pattern.
Based on your answers and the architecture guide, choose:
- Layered Architecture - Most projects should start here
- Clean Architecture - If long-term maintenance is critical
- Vertical Slice Architecture - If agile/rapid delivery is critical
| Scenario | Recommendation |
|---|---|
| First project, small team | Layered ✓ |
| Quick MVP needed | Layered ✓ |
| Complex domain, large team | Clean ✓ |
| Agile team, independent features | Vertical Slice ✓ |
| Unsure | Layered (safe default) ✓ |
# 1. Clone the entire repository
git clone https://github.com/entelect-incubator/Project-Templates.git
cd Project-Templates/backend/.NET
# 2. Choose your template
cd 1.LayeredArchitecture
# (or 2.CleanArchitecture, or 3.VerticalSliceArchitecture)# 1. Download the repository as ZIP
# https://github.com/entelect-incubator/Project-Templates/archive/refs/heads/master.zip
# 2. Extract and navigate
cd Project-Templates/backend/.NET/1.LayeredArchitecture
# 3. Copy to your project location
cp -r . ../../../MyNewProject
cd ../../../MyNewProject# Navigate to your chosen template
cd Project-Templates/backend/.NET/1.LayeredArchitecture
# Create a new solution from the template
dotnet new -i .# From the template root directory
dotnet restoreIf copying the template, rename projects to match your application:
# Example: Renaming from "CleanArchitecture" to "MyApp"
# Find and replace in:
# - Solution files (.sln)
# - Project files (.csproj)
# - Namespace declarationsEdit appsettings.json (in the API project):
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=MyAppDb;User Id=sa;Password=YourPassword;"
}
}Connection String Examples:
SQL Server (Local):
Server=.;Database=MyAppDb;Trusted_Connection=true;
SQL Server (Named Instance):
Server=.\SQLEXPRESS;Database=MyAppDb;Trusted_Connection=true;
PostgreSQL:
Host=localhost;Port=5432;Database=MyAppDb;Username=postgres;Password=password;
SQLite:
Data Source=myapp.db;
# Navigate to the API project directory
cd src/MyApp.Api
# Apply migrations to create database
dotnet ef database update
# Create a new migration (after model changes)
dotnet ef migrations add MigrationName
# Revert last migration
dotnet ef migrations remove# Navigate to API project
cd src/MyApp.Api
# Run with dotnet CLI
dotnet run
# Or run in watch mode (auto-restart on changes)
dotnet watch run
# Or use Visual Studio (F5)The API will be available at:
- HTTP:
http://localhost:5000 - HTTPS:
https://localhost:5001
Navigate to the Swagger UI:
https://localhost:5001/swagger/index.html
You can test all endpoints directly from the browser.
MyApp/
├── src/
│ ├── MyApp.Api/ # Web API layer
│ │ ├── Controllers/ # API endpoints
│ │ ├── Middleware/ # Custom middleware
│ │ ├── Filters/ # Action filters
│ │ ├── appsettings.json # Configuration
│ │ ├── Program.cs # Startup configuration
│ │ └── MyApp.Api.csproj
│ │
│ ├── MyApp.Application/ # Business logic
│ │ ├── Features/ # Feature modules
│ │ │ ├── Users/
│ │ │ ├── Products/
│ │ │ └── Orders/
│ │ ├── Behaviors/ # Pipeline behaviors
│ │ ├── Validators/ # Validation rules
│ │ ├── Exceptions/ # Custom exceptions
│ │ ├── AutoMapper/ # DTO mappings
│ │ └── MyApp.Application.csproj
│ │
│ ├── MyApp.Domain/ # Core entities
│ │ ├── Entities/ # Domain models
│ │ ├── Interfaces/ # Abstractions
│ │ ├── Specifications/ # Domain specs
│ │ ├── Exceptions/ # Domain exceptions
│ │ └── MyApp.Domain.csproj
│ │
│ ├── MyApp.Infrastructure/ # Data & services
│ │ ├── Data/
│ │ │ ├── ApplicationDbContext.cs
│ │ │ └── Migrations/
│ │ ├── Repositories/ # Data access
│ │ ├── Services/ # External services
│ │ └── MyApp.Infrastructure.csproj
│ │
│ └── MyApp.Shared/ # Cross-cutting
│ ├── Constants/
│ ├── Extensions/
│ ├── Exceptions/
│ └── MyApp.Shared.csproj
│
├── tests/
│ ├── MyApp.Application.Tests/ # Application tests
│ ├── MyApp.Domain.Tests/ # Domain tests
│ ├── MyApp.Api.Tests/ # API tests
│ └── MyApp.Integration.Tests/ # Integration tests
│
├── MyApp.sln # Solution file
├── README.md
└── .gitignore
src/MyApp.Api
- Entry point of the application
- HTTP request/response handling
- Swagger/OpenAPI configuration
- CORS and middleware setup
src/MyApp.Application
- Business logic implementation
- CQRS command/query handlers (if using MediatR)
- Data validation
- Cross-cutting concerns
src/MyApp.Domain
- Pure business entities
- Business logic that shouldn't depend on frameworks
- Contracts and interfaces
src/MyApp.Infrastructure
- Database context and migrations
- Repository implementations
- External service integrations
- Implementation details
tests/
- Unit tests for business logic
- Integration tests for API
- Test fixtures and helpers
# Build solution
dotnet build
# Build with specific configuration
dotnet build -c Release
# Clean build
dotnet clean && dotnet build# Run all tests
dotnet test
# Run tests with coverage
dotnet test /p:CollectCoverage=true
# Run specific test project
dotnet test tests/MyApp.Application.Tests
# Run with verbose output
dotnet test -v d# Add to specific project
dotnet add MyApp.Application package MediatR
# Add specific version
dotnet add MyApp.Application package MediatR --version 12.0.0
# List packages
dotnet package list# Create new migration
dotnet ef migrations add AddUserTable -p src/MyApp.Infrastructure -s src/MyApp.Api
# Update database
dotnet ef database update -p src/MyApp.Infrastructure -s src/MyApp.Api
# Remove migrations
dotnet ef migrations remove -p src/MyApp.Infrastructure -s src/MyApp.Api
# Create SQL script
dotnet ef migrations script -p src/MyApp.Infrastructure -s src/MyApp.Api -o migrations.sql# Format all code
dotnet format
# Show formatting issues without applying
dotnet format --verify-no-changes
# Format specific file
dotnet format path/to/file.cs# Publish to Release folder
dotnet publish -c Release -o ./publish
# Create Docker image (if Dockerfile exists)
docker build -t myapp .
# Publish to folder for deployment
dotnet publish -c Release --self-contained -r win-x64 -o ./publish-
Update Solution File:
- Open
MyApp.slnin an editor - Replace
MyAppwith your project name
- Open
-
Rename Project Folders:
ren src\MyApp.Api src\YourApp.Api ren src\MyApp.Application src\YourApp.Application # ... and so on
-
Update Project Files:
- Open each
.csprojfile - Update assembly name and root namespace
- Open each
-
Update Namespaces:
- Search and replace
MyApp→YourAppacross all files
- Search and replace
-
Update appsettings.json:
- Update any references to the old project name
- Create domain entity (
src/MyApp.Domain/Entities/User.cs) - Create commands/queries (
src/MyApp.Application/Features/Users/) - Create handlers (
src/MyApp.Application/Features/Users/Handlers/) - Create controller (
src/MyApp.Api/Controllers/UsersController.cs) - Add migrations for database changes
- Add tests (
tests/MyApp.Application.Tests/Features/Users/)
# 1. Make changes to your domain entities
# 2. Create migration
dotnet ef migrations add DescriptiveChangeName
# 3. Review the generated migration file
# 4. Update database
dotnet ef database updateSolution:
# Ensure you're in the correct directory with DbContext
dotnet ef migrations list -p src/MyApp.Infrastructure -s src/MyApp.Api
# Verify DbContext is registered in DI container (Program.cs)Solution:
# 1. Verify connection string in appsettings.json
# 2. Ensure database server is running
# 3. Check firewall rules
# 4. Test connection with sqlcmd or pgAdminSolution:
# Change the port in launchSettings.json or use:
dotnet run --urls "https://localhost:7777"
# Or kill the process using the port
# Windows: netstat -ano | findstr :5001
# Linux/Mac: lsof -i :5001Solution:
# Verify .NET installation
dotnet --version
# If needed, download and install from:
https://dotnet.microsoft.com/download
# Check global.json version requirement (if present)
cat global.jsonSolution:
# 1. Clean solution
dotnet clean
# 2. Remove bin/obj folders
rm -r src/*/bin src/*/obj tests/*/bin tests/*/obj
# 3. Restore packages
dotnet restore
# 4. Rebuild
dotnet buildSolution:
# Ensure test appsettings.json exists
# Copy appsettings.json to test project if needed
# Verify test project has proper configuration
# Run with verbose output
dotnet test -v dOnce you have the template running:
- Read the Architecture Guide - Understand your chosen pattern
- Explore the Examples - Each template includes example features
- Review Test Examples - See how testing is structured
- Add Your First Feature - Extend the template with your logic
- Join the Community - Contribute improvements back
- GitHub Issues - Report bugs or ask questions
- GitHub Discussions - General questions and best practices
- See Also
- ARCHITECTURE.md - Pattern comparison and explanation
- README.md - Project overview
- CONTRIBUTING.md - Contributing guidelines
- backend/.NET/README.md - .NET specific documentation
✅ Start Small - Understand the template structure before adding complexity ✅ Keep Dependencies Clean - Respect the architecture's dependency rules ✅ Write Tests - Each new feature should have tests ✅ Document Decisions - Explain why you made architectural choices ✅ Code Reviews - Review changes to maintain consistency ✅ Consistent Naming - Use clear, descriptive names throughout ✅ Refactor Regularly - Improve code quality as you go
Happy Coding! 🚀
Built with ❤️ by the Entelect Incubator team