{"record":{"id":"bdd58372c0cd50c0","repo":"dotnet/efcore","slug":"navigation-entitytype-navigationname-doesn-t-bdd583","errorCode":null,"errorMessage":"Navigation '{entityType}.{navigationName}' doesn't point to an embedded entity.","messagePattern":"Navigation '(.+?)\\.(.+?)' doesn't point to an embedded entity\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Query/Internal/Expressions/ObjectArrayAccessExpression.cs","lineNumber":40,"sourceCode":"    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public ObjectArrayAccessExpression(\n        Expression @object,\n        IPropertyBase structuralProperty,\n        StructuralTypeProjectionExpression? innerProjection = null)\n    {\n        ITypeBase targetType;\n        string propertyName;\n\n        switch (structuralProperty)\n        {\n            case INavigation navigation:\n                targetType = navigation.TargetEntityType;\n                propertyName = navigation.TargetEntityType.GetContainingPropertyName()\n                    ?? throw new InvalidOperationException(\n                        CosmosStrings.NavigationPropertyIsNotAnEmbeddedEntity(\n                            navigation.DeclaringEntityType.DisplayName(), navigation.Name));\n                break;\n            case IComplexProperty complexProperty:\n                targetType = complexProperty.ComplexType;\n                propertyName = complexProperty.GetJsonPropertyName();\n                break;\n            default:\n                throw new UnreachableException($\"Unexpected structural property type: {structuralProperty.GetType().FullName}\");\n        }\n\n        PropertyName = propertyName;\n        Type = typeof(IEnumerable<>).MakeGenericType(targetType.ClrType);\n        StructuralProperty = structuralProperty;\n        Object = @object;\n        InnerProjection = innerProjection\n            ?? new StructuralTypeProjectionExpression(new ObjectReferenceExpression(targetType, \"\"), targetType);\n    }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Query/Internal/Expressions/ObjectArrayAccessExpression.cs#L22-L58","documentation":"ObjectArrayAccessExpression reads a JSON array of embedded objects (used for collection navigations/complex collections). Like its single-object counterpart, it throws InvalidOperationException when given a navigation whose target is not embedded (no containing property name). Only embedded collection navigations are representable on Cosmos.","triggerScenarios":"Querying a collection navigation (e.g. .SelectMany, .Any on children) that is not configured as OwnsMany/complex collection, so Cosmos cannot embed it.","commonSituations":"Relational-style one-to-many FK collections migrated to Cosmos without OwnsMany; querying child collections as if joins existed.","solutions":["Map the collection as embedded owned: builder.Entity<Root>().OwnsMany(r => r.Items).","Avoid server-side queries over non-embedded collections; load the root and filter client-side, or split into separate container queries.","Use a complex collection (complex type list) if the children are value objects."],"exampleFix":"// before\nvar q = ctx.Orders.Where(o => o.Items.Any(i => i.Sku == \"x\"));\n// where Items is a plain navigation -> throws\n\n// after\nmodelBuilder.Entity<Order>().OwnsMany(o => o.Items);\nvar q = ctx.Orders.Where(o => o.Items.Any(i => i.Sku == \"x\"));","handlingStrategy":"validation","validationCode":"static bool IsEmbeddedCollection(INavigation n)\n    => n.IsCollection && n.TargetEntityType.GetContainingPropertyName() is not null;\nvar nav = cosmosModel.FindEntityType(typeof(Order))!.FindNavigation(nameof(Order.Items))!;\nif (!IsEmbeddedCollection(nav))\n    throw new InvalidOperationException(\"Configure Items as OwnsMany.\");","typeGuard":"static bool CollectionNavigationIsEmbedded(IEntityType owner, string navName)\n    => owner.FindNavigation(navName) is { IsCollection: true } n\n       && n.TargetEntityType.GetContainingPropertyName() is not null;","tryCatchPattern":"try { var q = ctx.Orders.Where(o => o.Items.Any(i => i.Sku == \"x\")).ToList(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"doesn't point to an embedded entity\"))\n{ /* map as OwnsMany or filter client-side */ }","preventionTips":["Configure collection children as OwnsMany or complex collections.","Do not expect server joins for non-embedded collections on Cosmos.","Write a test that exercises each collection navigation in a query."],"tags":["cosmos","navigation","owned-collection","embedding"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}