https://github.com/charliedigital/efcore-m2m
Reproduction repo for EFCore M2M mapping sub-select issue.
https://github.com/charliedigital/efcore-m2m
Last synced: 9 months ago
JSON representation
Reproduction repo for EFCore M2M mapping sub-select issue.
- Host: GitHub
- URL: https://github.com/charliedigital/efcore-m2m
- Owner: CharlieDigital
- Created: 2023-03-08T22:54:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-09T15:55:37.000Z (over 3 years ago)
- Last Synced: 2025-07-31T03:39:09.169Z (11 months ago)
- Language: C#
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reproduction of Inefficient Sub-Select in EFCore 7.0
See this GitHub issue: https://github.com/dotnet/efcore/issues/17622
## Output Query for EFCore7 M2M
```sql
SELECT p.id, p.created_utc, p.name, t.product_id, t.media_id, t.id, t.created_utc, t.name
FROM products AS p
LEFT JOIN (
SELECT p0.product_id, p0.media_id, m.id, m.created_utc, m.name
FROM product_media AS p0
INNER JOIN media AS m ON p0.media_id = m.id
) AS t ON p.id = t.product_id
ORDER BY p.id, t.product_id, t.media_id
```
## To run:
```
docker compose up -d
dotnet run
curl http://localhost:5256/init & curl http://localhost:5256/products | jq .
```