Support separate navigation query and update mappings, including read-only navigations
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start with the parent tracker #20339 and the related issues #20337 and #33171 to understand how this work is divided. The issue calls for design across navigation metadata, query translation and loading, change tracking, model finalization, and compiled models; no specific files or tests are named. Done means defining and implementing query-only and separate query/update navigation mappings with clear mutation behavior and lifecycle support.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A navigation used to query related entities does not always represent an association that can be changed by assigning the reference or adding/removing collection elements. Its query mapping may also differ from the target entity type's normal query source or from the relationship used to persist association changes.
Similarly, a model may expose both a read-only relationship and a derived, writable navigation to the same target entity type. These navigations need different query semantics without inventing additional persistence relationships.
Current ordinary navigation metadata is tied to a foreign key. Navigation mutation and relationship fixup operate on that relationship. This does not provide an independent contract for a query-only association.
Existing support and workarounds
EF already supports some separation at the entity-type level: an entity can be queried through a view and updated through a table. This issue should preserve and build on that behavior, not reintroduce it as a new feature.
However, entity-type table/view mapping does not independently describe how a particular navigation is queried or whether mutations to its association can be persisted.
Neither a getter-only property nor IReadOnlyCollection<T> establishes this semantic distinction. EF can populate navigations through backing fields and collection accessors, and CLR API shape alone does not specify persistence behavior. Likewise, AsNoTracking controls tracking of query results rather than declaring an association read-only.
Explicit LINQ queries/projections can compute derived associations today, but do not provide a reusable mapped navigation with ordinary loading semantics.
Describe the solution you'd like
Separate the metadata and behavior used to query a navigation from the relationship/update mapping used to persist changes to its association.
Allow an explicitly configured query-only navigation with no association update mapping. Allow an independently configured update mapping where a persistable relationship exists. The exact configuration API and supported combinations need design.
"Read-only navigation" should mean that EF does not infer or persist association changes from that navigation. It should not mean that the returned entity instances are necessarily read-only, keyless, or untracked.
Design considerations
- Query mapping: Describe navigation query semantics independently of the target entity type's default mapping and of any writable relationship. Query translation and loading must consistently honor that mapping.
- Association mutation: Define what happens when a read-only reference is assigned or a read-only collection is changed, including changes made through backing fields or the change-tracking API. Unsupported attempts to persist association changes should have explicit diagnostics rather than silently succeeding or changing another relationship.
- Materialization and fixup: EF must still be able to populate query-only navigations. Distinguish internal materialization/fixup from application mutation. Define whether and how already-tracked entities participate; fixup must not populate a derived navigation using only the target's ordinary foreign-key relationship.
- Entity updates: Returned keyed entities can retain their normal update mapping. Updating their scalar properties should not require the navigation association itself to be writable.
- Relationship side effects: Query-only associations must not introduce synthetic foreign keys, join tables, cascade deletes, orphan deletion, or ownership semantics merely to represent their query behavior.
- Consistency: Define loaded-state and reload behavior when source or target properties affecting membership change. Do not imply that arbitrary database-defined associations can always be maintained automatically in memory.
- Writable mappings: When both query and update mappings exist, define how reference/collection changes affect the writable relationship, including inverse navigations, and how discrepancies between queried membership and writable membership are handled.
- Metadata lifecycle: Preserve configuration through conventions, model finalization, runtime/compiled models and snapshots where applicable. Query-only metadata should not produce spurious schema operations.
Scope and related work
- #20339 is the parent tracker for flexible navigation mapping.
- #20337 tracks a specific consumer: implicit many-to-many associations without a join table.
- #33171 tracks custom joins/query mappings for read-only navigations. This issue supplies the query/update separation and mutability contract, rather than the syntax or translation of arbitrary joins.
- Mapping navigations to database functions is another consumer of this separation and should have its own focused tracker under #4319/#20339.
- General immutability of entity instances, new query-source forms, and automatic in-memory reevaluation of arbitrary queries are not required by this issue.
- Lingua principale
- C#
- Stelle
- 14.8k
- Fork
- 3.4k
- Merge medio
- 3g 18h
- PR unite (30g)
- 159
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotnet/efcore
-
customer-reported
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
-
Regression in 11.0: replacing an owned instance or re-adding an entity with the same key sets unchanged OnAdd properties to nullForse già presa @seragAhmed l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
dotnet/efcore#39617 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
customer-reported
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di dotnet/efcore
Issue simili
-
bug emitter:client:csharp
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/typespec#12572 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
needs-area-label
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
newrelic/newrelic-dotnet-agent#3949 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area-networking
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dotnet/aspnetcore#70545 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno