Skip to content

Cosmos: NullReferenceException when projecting out an owned entity which doesn't own additional entity types #34068

Closed

Description

@roji

@ajcvickers the following throws an NRE from the shaper; it may be triggered by bad processing on my side of the fence, but can you take a look (in any case we probably shouldn't be throwing NRE):

public virtual Task Project_owned_reference_navigation_which_does_not_own_additional(bool async)
    => AssertQuery(
        async,
        ss => ss.Set<OwnedPerson>().OrderBy(o => o.Id).Select(p => p.PersonAddress.Country));

Exception:

System.NullReferenceException
Object reference not set to an instance of an object.
   at lambda_method1037(Closure, QueryContext, JObject)
   at Microsoft.EntityFrameworkCore.Cosmos.Query.Internal.CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync() in /Users/roji/projects/efcore/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs:line 269
   at Microsoft.EntityFrameworkCore.Cosmos.Query.Internal.CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync() in /Users/roji/projects/efcore/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs:line 292
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) in /Users/roji/projects/efcore/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs:line 2303

Activity

  1. added this to the 9.0.0 milestone on Jun 22, 2024
  2. modified the milestones: 9.0.0, on Aug 21, 2024
  3. removed their assignment
    on Aug 31, 2024
  4. modified the milestones: , 9.0.0 on Oct 12, 2024
  5. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions