Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AlexanderAsprilla98/Tournament-Management-App/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Tournament Management App uses Entity Framework Core with support for both SQLite (default) and SQL Server databases. The application maintains two separate database contexts for different purposes.Database Contexts
The application uses two Entity Framework Core contexts:DataContext
Purpose: Tournament domain dataEntities:
- Municipios (Municipalities)
- DirectoresTecnicos (Technical Directors)
- Equipos (Teams)
- Jugadores (Players)
- Partidos (Matches)
- Posiciones (Positions)
IdentityDataContext
Purpose: User authenticationEntities:
- AspNetUsers
- AspNetRoles
- AspNetUserClaims
- AspNetRoleClaims
- DataProtectionKeys
Database Providers
SQLite (Default)
SQLite is the default database provider, ideal for development and small deployments: Advantages:- No separate database server required
- File-based storage
- Zero configuration
- Perfect for development and testing
Program.cs
/app/Torneo.db inside the Docker container, or in the application directory for local development.
SQL Server
For production deployments with higher load, you can use SQL Server: Advantages:- Better performance at scale
- Advanced features (stored procedures, full-text search)
- Enterprise support and tooling
- Concurrent access handling
Update DbContext configuration
The application automatically detects SQL Server connection strings. No code changes needed.
Initial Setup
Docker Deployment (Automatic)
When using Docker, migrations run automatically during image build:Dockerfile (lines 19-35)
Local Development (Manual)
For local development without Docker:Database Schema
Tournament Domain Tables
| Table | Description | Key Relationships |
|---|---|---|
| Municipios | Cities/municipalities where teams are based | Referenced by Equipos |
| DirectoresTecnicos | Technical directors (coaches) | Referenced by Equipos |
| Equipos | Tournament teams | References Municipio, DirectorTecnico; has many Jugadores and Partidos |
| Jugadores | Players on teams | References Equipo and Posicion |
| Posiciones | Player positions (Goalkeeper, Defender, etc.) | Referenced by Jugadores |
| Partidos | Matches between teams | References two Equipos (Local and Visitante) |
Identity Tables
| Table | Description |
|---|---|
| AspNetUsers | User accounts with email and password |
| AspNetRoles | User roles for authorization |
| AspNetUserRoles | User-to-role assignments |
| AspNetUserClaims | Additional user claims |
| AspNetUserLogins | External authentication providers |
| DataProtectionKeys | Encryption keys for data protection |
Entity Relationships
Migration Management
List Migrations
View applied and pending migrations:Create New Migration
When you modify entity models:Rollback Migration
To undo the last migration:Generate SQL Script
To review SQL without applying changes:Database Seeding
To add initial data, you can seed the database inDataContext.cs using the OnModelCreating method:
Example Seeding
Health Checks
The application includes database health checks configured inProgram.cs:
Program.cs (lines 43-44)
Backup and Restore
SQLite Backup
For SQLite databases, simply copy the database file:SQL Server Backup
For SQL Server, use standard backup commands:Troubleshooting
Migration fails with 'context not found' error
Migration fails with 'context not found' error
Solution: Ensure you specify the correct context and projects:Always use the full namespace for the context.
Database locked errors (SQLite)
Database locked errors (SQLite)
Solution: SQLite doesn’t handle concurrent writes well. Ensure:
- Only one process accesses the database at a time
- Close all connections properly
- For high-concurrency scenarios, use SQL Server instead
Foreign key constraint violations
Foreign key constraint violations
Solution: The application uses
DeleteBehavior.Restrict to prevent cascading deletes. You must:- Delete dependent records first (e.g., delete Jugadores before deleting Equipo)
- Or update relationships to null before deletion
Connection string not found
Connection string not found
Solution: Set the Or update
DATABASE_CONNECTION_STRING environment variable:appsettings.json:'dotnet ef' command not found
'dotnet ef' command not found
Solution: Install Entity Framework Core tools globally:Add to PATH if needed:
Next Steps
Data Context API
Explore the DataContext and IdentityDataContext APIs
Migrations Guide
Learn about Entity Framework Core migrations
Configuration
Configure environment variables and settings
Domain Models
Review the entity models and relationships