efcore icon indicating copy to clipboard operation
efcore copied to clipboard

When to trigger IMaterializationInterceptor if materialization is not from a query?

Open Li7ye opened this issue 1 year ago • 0 comments

From documentation : The IMaterializationInterceptor supports interception before and after an entity instance is created, and before and after properties of that instance are initialized.

In most case, the interceptor is triggered from query. But there is a property QueryTrackingBehavior? QueryTrackingBehavior in MaterializationInterceptionData. The comment say if it is null, this materialization is not from a query.

As far as I know, when use InMemeory or Cosmos provider with model data seeding and call dbContext.Database.EnsureCreated() will trigger IMaterializationInterceptor. And, call entityEntry.GetDatabaseValues().ToObject() method as well.

Could you please help to summarize the all scenarios of triggering IMaterializationInterceptor for the materialization is not from query?

EF Core version: 8.0.0 Target framework: .NET 8.0 Operating system: Windows IDE: (Visual Studio 2022)

Li7ye avatar Apr 26 '24 03:04 Li7ye