dotnet / dotnet/efcore

Add an interception point for navigation property fix-up

Open
#35,951 16 comments 1 reaction 1 assignee Claimed by @AndriySvyryd View on GitHub
area-interception customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

### Question

I'm trying to figure out how to access navigation properties when data is loaded. I've tried `IMaterializationInterceptor.InitializedInstance` and `ChangeTracker.Tracked`. Neither executes **after** applying the navigation properties. Similar questions have been asked, but I don't see any solutions that work:

[https://github.com/dotnet/efcore/issues/32535](https://github.com/dotnet/efcore/issues/32535)
[https://github.com/dotnet/efcore/issues/35386](https://github.com/dotnet/efcore/issues/35386)

In [https://github.com/dotnet/efcore/issues/32535](https://github.com/dotnet/efcore/issues/32535), there's a suggestion for interception after the result set has been consumed. Apparently it's described somewhere at [https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/interceptors#database-interception](https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/interceptors#database-interception). But they all look like intercepts that happen prior to properties being set on the objects, so that does no good.

For some context, my objects implement `INotifyPropertyChanged` and I'm simply trying to wire child objects to their parents, so that the parents know when a child property has changed. I suppose everywhere that I retrieve data, I could execute code to traverse the object graph and do the wiring, but that seems like a bad way to do it.

### Your code

```csharp

```

### Stack traces

```text

```

### Verbose output

```text

```

### EF Core version

9.0.3

### Database provider

Microsoft.EntityFrameworkCore.SqlServer

### Target framework

.NET 9.0

### Operating system

Windows 10

### IDE

Visual Studio Enterprise 2022 17.13.6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.