feat: add efcore-d2-db-diagram skill and related documentation (#1821)

This commit is contained in:
Mikael
2026-05-25 03:34:34 +02:00
committed by GitHub
parent 59fdc7867a
commit c9dace874d
7 changed files with 482 additions and 0 deletions
@@ -0,0 +1,59 @@
# Relationship Rules
## One-to-many
Detected from:
- `HasOne(...).WithMany(...)`
- FK property on dependent entity.
- Collection navigation on principal entity.
Render dependent to principal:
```d2
Orders.ClientId -> Clients.Id: "N:1"
```
## One-to-one
Detected from:
- `HasOne(...).WithOne(...)`
- Unique FK index.
- Shared primary key relationship.
Render dependent to principal:
```d2
ClientProfiles.ClientId -> Clients.Id: "1:1"
```
## Many-to-many
Detected from:
- `UsingEntity`
- Two collection navigations without explicit join entity.
- Migration-created join table with two FKs and composite key.
Render the join table explicitly by default.
## Owned types
Detected from:
- `OwnsOne`
- `OwnsMany`
- `[Owned]`
Inline by default unless table splitting or separate table mapping is detected.
## Optional relationships
A relationship is optional when:
- FK is nullable.
- `IsRequired(false)` is configured.
- Migration column is nullable.
Use dashed line for optional relationships.