Skip to main content

Overview

The Equipo (Team) entity represents a football team in the tournament management system. Each team belongs to a municipality, has a technical director, consists of multiple players, and participates in matches as either the home (local) or visiting team.

Properties

int
Unique identifier for the team.
string
required
Name of the team.Validation Rules:
  • Required field (cannot be empty)
  • Must contain letters, numbers, and spaces
  • Cannot consist of numbers only
  • Minimum length: 3 characters
  • Maximum length: 50 characters
  • Regex pattern: ^(?![0-9]+$)[a-zA-ZÀ-ÿ\d\s]+$
Default Value: Empty stringDisplay Name: “Nombre del Equipo”Error Messages:
  • Pattern mismatch: “Valor Incorrecto. Solo se permiten letras”
  • Required: “El nombre del Equipo es obligatorio.”
  • Max length: “El nombre del equipo no puede contener más de 50 caracteres”
  • Min length: “El nombre del equipo no puede contener menos de 3 caracteres”
Municipio?
The municipality where the team is based.Nullable: YesRelationship: Many-to-One (Many teams can belong to one municipality)Related Entity: Municipio
DirectorTecnico?
The technical director (coach) of the team.Nullable: YesRelationship: Many-to-One (Many teams can have one technical director)Related Entity: DirectorTecnico
List<Jugador>?
Collection of players belonging to this team.Nullable: YesDefault Value: Empty listRelationship: One-to-Many (One team has multiple players)Related Entity: Jugador
List<Partido>?
Collection of matches where this team plays as the home team.Nullable: YesDefault Value: Empty listRelationship: One-to-Many (One team plays multiple matches as home team)Inverse Property: LocalRelated Entity: Partido
List<Partido>?
Collection of matches where this team plays as the visiting team.Nullable: YesDefault Value: Empty listRelationship: One-to-Many (One team plays multiple matches as visiting team)Inverse Property: VisitanteRelated Entity: Partido

Relationships

The Equipo entity has several important relationships:

Municipality (Municipio)

Municipio
Each team belongs to one municipality. This is a many-to-one relationship.Navigation Property: MunicipioRelated Entity: Municipio

Technical Director (DirectorTecnico)

DirectorTecnico
Each team is coached by one technical director. This is a many-to-one relationship.Navigation Property: DirectorTecnicoRelated Entity: DirectorTecnico

Players (Jugadores)

List<Jugador>
A team consists of multiple players. This is a one-to-many relationship.Navigation Property: JugadoresRelated Entity: Jugador

Home Matches (PartidosLocal)

List<Partido>
Collection of matches where the team plays as the home team. Uses [InverseProperty("Local")] to establish the relationship.Navigation Property: PartidosLocalInverse Property: Local in Partido entityRelated Entity: Partido

Away Matches (PartidosVisitante)

List<Partido>
Collection of matches where the team plays as the visiting team. Uses [InverseProperty("Visitante")] to establish the relationship.Navigation Property: PartidosVisitanteInverse Property: Visitante in Partido entityRelated Entity: Partido

Validation Attributes

The Equipo entity uses the following Data Annotations:
  • [Required] - Ensures the team name is mandatory
  • [RegularExpression] - Validates name format (letters, numbers, spaces)
  • [MaxLength] / [MinLength] - Enforces character length constraints
  • [Display] - Provides user-friendly display name
  • [InverseProperty] - Configures bidirectional navigation for matches
The [InverseProperty] attributes are crucial for distinguishing between home and away matches, allowing Entity Framework to properly map the two separate relationships to the Partido entity.

Code Examples

Entity Definition

Creating a Team

Creating a Team with Players

Valid Name Examples

Invalid Name Examples

These examples will fail validation:

Accessing Match History

Querying Team Players by Position

Database Mapping

The Equipo entity is mapped to a database table with the same name. The Id property serves as the primary key and is auto-generated.Foreign keys are created for:
  • Municipio relationship
  • DirectorTecnico relationship
The inverse properties (PartidosLocal and PartidosVisitante) are configured to prevent ambiguous foreign key references in the Partido entity.