You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
@Li7ye This happens when the entity instance is created by the DbContext outside of any particular query. For example, EF may create instances of join entities when attaching either end of a many-to-many relationship. Similarly, creating new instances from data in the change tracker is another place. I don't have the full list of possibilities available off the top of my head, and new scenarios are likely to be added in the future.
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
inMaterializationInterceptionData
. The comment say if it is null, this materialization is not from a query.As far as I know, when use
InMemeory
orCosmos
provider with model data seeding and calldbContext.Database.EnsureCreated()
will triggerIMaterializationInterceptor
. And, callentityEntry.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)
The text was updated successfully, but these errors were encountered: