{"record":{"id":"ae6ff075b03faeda","repo":"dotnet/efcore","slug":"navigation-entitytype-navigationname-doesn-t","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/ObjectAccessExpression.cs","lineNumber":38,"sourceCode":"    /// <summary>\n    ///     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 ObjectAccessExpression(\n        Expression @object,\n        IPropertyBase structuralProperty)\n    {\n        ITypeBase structuralType;\n        string propertyName;\n\n        switch (structuralProperty)\n        {\n            case INavigation navigation:\n                structuralType = 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                structuralType = 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        StructuralProperty = structuralProperty;\n        Object = @object;\n        StructuralType = structuralType;\n    }\n\n    /// <summary>","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Query/Internal/Expressions/ObjectAccessExpression.cs#L20-L56","documentation":"ObjectAccessExpression reads a JSON object embedded in a Cosmos document (used for owned entities and complex properties accessed via a navigation). When constructed with an INavigation whose target entity type has no 'containing property name' (i.e. the navigation is NOT mapped as embedded JSON), it throws InvalidOperationException. Cosmos supports only navigations that are embedded in the same document.","triggerScenarios":"Querying (filtering/projecting/navigating) a navigation that is not configured as owned (OwnsOne/OwnsMany) or as a complex type, since Cosmos has no server-side join for non-embedded relationships.","commonSituations":"Porting a relational model to Cosmos where relationships are modeled as plain foreign keys; forgetting OwnsOne; adding a navigation and querying it before configuring embedding.","solutions":["Configure the target entity as owned in the same document: builder.Entity<Root>().OwnsOne(r => r.Embedded).","If it must be a separate aggregate, do not navigate to it inside a Cosmos-translated query; load it via a separate query.","For complex values, use a complex property (OwnsOne complex type) instead of an entity navigation."],"exampleFix":"// before\nmodelBuilder.Entity<Order>().HasOne(o => o.Customer)\n    .WithMany().HasForeignKey(o => o.CustomerId);\nvar q = ctx.Orders.Where(o => o.Customer.Name == \"x\"); // throws\n\n// after: embed as owned\nmodelBuilder.Entity<Order>().OwnsOne(o => o.Customer);","handlingStrategy":"validation","validationCode":"// Verify a navigation is embedded before querying it.\nstatic bool IsEmbedded(INavigation n)\n    => n.TargetEntityType.GetContainingPropertyName() is not null;\nvar nav = cosmosModel.FindEntityType(typeof(Order))!.FindNavigation(nameof(Order.Customer))!;\nif (!IsEmbedded(nav)) throw new InvalidOperationException(\"Configure Customer as owned.\");","typeGuard":"static bool NavigationIsEmbedded(IEntityType owner, string navName)\n    => owner.FindNavigation(navName)?.TargetEntityType.GetContainingPropertyName() is not null;","tryCatchPattern":"try { var q = ctx.Orders.Where(o => o.Customer.Name == \"x\").ToList(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"doesn't point to an embedded entity\"))\n{ /* reconfigure as OwnsOne or load client-side */ }","preventionTips":["Model embedded entities with OwnsOne/OwnsMany in the same document.","Audit navigations when porting a relational model to Cosmos.","Add a model-validation test asserting all queried navigations are embedded."],"tags":["cosmos","navigation","owned-entity","embedding"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}