dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.8k stars 3.2k forks source link

Cosmos: querying an entity with a nested owned collection throws #18265

Closed TeaBaerd closed 5 years ago

TeaBaerd commented 5 years ago

I have an item object that is an entity in an EF Core 3 DbContext that is pointing to a Cosmos Db. When I try to retrieve the record from the DbContext, I get the following exception: An exception of type 'System.InvalidOperationException' occurred in System.Linq.Expressions.dll but was not handled in user code: 'When called from 'VisitLambda', rewriting a node of type 'System.Linq.Expressions.ParameterExpression' must return a non-null value of the same type. Alternatively, override 'VisitLambda' and change it to not visit children of this type.'

This error is only thrown when the Item's object owns many ItemImages and ItemImages Owns many ImageAttributes. The AddAsync command thows no error when this information is added to a CosmosDb store but it will error every time on retrieval.

Any attempt to do a FirstOrDefaultAsync or FindAsync results in the error.

Steps to reproduce

I have attached sample code in a repository using VS code and the Cosmos Emulator. https://github.com/TeaBaerd/CosmosEfCoreOwnsManyOwnsMany

ajcvickers commented 5 years ago

@AndriySvyryd We've been waiting for you to triage this. Thoughts?

AndriySvyryd commented 5 years ago

It's a bug

smitpatel commented 5 years ago

@AndriySvyryd - Assignee?