-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Labels
.NETPull requests that update .NET codePull requests that update .NET codeenhancementNew feature or requestNew feature or request
Description
Description
To improve API design and encapsulate internal identifiers, we'll switch from using long/incremental IDs to Guid as the primary key (Id) for the Player entity. The externally visible and unique identifier will be SquadNumber, aligning with real-world conventions (e.g., tracking numbers in logistics or jersey numbers in sports).
This change improves separation between internal persistence concerns and public API contracts. Using a Guid makes the Id explicitly internal, while SquadNumber is more domain-meaningful for clients.
Suggested Approach
- Replace
long IdwithGuid Idin thePlayerentity, with default value set viaGuid.NewGuid(). - Retain
SquadNumberas a required, unique, externally meaningful identifier. - Update
OnModelCreating:- Set
.HasKey(p => p.Id)and.Property(p => p.Id).ValueGeneratedOnAdd() - Add
.HasIndex(p => p.SquadNumber).IsUnique()
- Set
- Reset the database and create a new initial migration (for educational purposes).
- Seed logic should continue working, now generating players with
GuidIDs. - Update DELETE endpoints (and others if needed) to use
SquadNumberinstead ofIdfor public-facing operations.
Acceptance Criteria
Player.Idis of typeGuid, generated viaGuid.NewGuid().SquadNumberis unique and used as the public-facing identifier (e.g., in DELETE endpoints).- Fluent configuration updated accordingly in
OnModelCreating. - A new clean initial EF Core migration exists reflecting the new schema.
- The seeded database works as expected on app startup with the new identifier model.
- Controllers and services updated to rely on
SquadNumberin routes and validation, where appropriate.
Resources
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .NET codePull requests that update .NET codeenhancementNew feature or requestNew feature or request