Problem
QueryableEncryptionSchemaGenerator.AddSchemaFields (src/MongoDB.EntityFrameworkCore/Infrastructure/QueryableEncryptionSchemaGenerator.cs) loops over entityType.GetNavigations() and recurses into every navigation whose target entity type is owned. For an owned type, GetNavigations() also returns the dependent-to-principal back-navigation (declared with .WithOwner(x => x.Parent)). When the owner is itself owned, that back-navigation passes the IsOwned() check and the recursion cycles forever.
The process dies with a StackOverflow, which cannot be caught.
Status of the diagnosis
The cause above is suspected and not yet verified. The trigger may be wider than the nested case. The shapes to confirm, each with a back-reference on the owned type:
- a root owner
- a nested owned type
- an owned collection
Proposed fix
Only follow navigations that point from the owner to the owned dependent, for example by skipping navigations where IsOnDependent is true. This is correct by construction, unlike a visited-set cycle breaker.
Schema output for models that work today must not change.
Also check
Other GetNavigations() walks in src/ that recurse over owned types. A similar defect was already fixed in StreamingEligibility on EF-322c (commit 6ce7f707).
Tests
Owned types with WithOwner, covering the root, nested and collection shapes plus an encrypted property on the owned type. Assert exact path values with no duplicates. Queryable-encryption tests skip silently unless CRYPT_SHARED_LIB_PATH is set.