Closed arex388 closed 4 months ago
This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.
Here is a project that is as close as I could get it to my actual project that demonstrates the error. There is a database creation script and readme. The database creation script has to be ran twice to work correctly.
I'm running into an issue when attempting to project an entity into a DTO, where the entity has a collection of JSON objects that has a nested collection of JSON objects, causes a
NullReferenceException
to be thrown. If I ignore the nested collection, the projection works as expected. The following is some code snippets to show the models, configurations, and the commands and queries I'm using. If needed I can try and make a standalone project, but for now I'm posting snippets of my attempt to reproduce with a smaller entity within my existing project.The project is an ASP.NET Core MVC app on .NET 8. It uses StronglyTypedIds, MediatR, AutoMapper, and FluentValidation. The database JSON payload does not have any null values.
Table Definition and Data
EF Core Models
EF Core Configurations
EF Core Context
Edit Command and Query
Stack Trace
Include provider and version information
EF Core version: 8.0.4 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 8.0 Operating system: Windows 10 Pro 22H2 IDE: Visual Studio 2022 17.9.6