Materialization Interceptor causing null navigation properties

NATHAN B 0 Reputation points
2025-01-30T18:13:11.7933333+00:00

I'm implementing IMaterializationInteceptor.InitializedInstance:

https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.diagnostics.imaterializationinterceptor?view=efcore-9.0

If I access a navigation property on the object being materialized, it is causing all kinds of null navigation properties afterwards outside the interceptor. Why does this happen?

I have an unmapped property I'm trying to populate that depends on navigating down one of it's navigation properties. I am able to access those entities just fine inside the interceptor and perform the calculation, but then after the interceptor is done, I am getting null navigation properties on entities.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
776 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.