-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Milestone
Description
I added an IMaterializationInterceptor like below (the exceptions are for this purpose only):
public class MaterializationInterceptor : IMaterializationInterceptor
{
private MaterializationInterceptor() { }
public object CreatedInstance(MaterializationInterceptionData materializationData, object entity)
{
throw new Exception("CreatedInstance");
}
public InterceptionResult<object> CreatingInstance(MaterializationInterceptionData materializationData, InterceptionResult<object> result)
{
throw new Exception("CreatingInstance");
}
public object InitializedInstance(MaterializationInterceptionData materializationData, object instance)
{
throw new Exception("InitializedInstance");
}
public InterceptionResult InitializingInstance(MaterializationInterceptionData materializationData, object entity, InterceptionResult result)
{
throw new Exception("InitializingInstance");
}
public static MaterializationInterceptor Instance { get; } = new();
}
Added to my contect as:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.AddInterceptors(
MaterializationInterceptor.Instance,
DbCommandInterceptor.Instance
);
}
When I run a query against my context I didn't get the expected result from the value substitution I have in the "InitializedInstance" method.
During debugging I can see that the constructor is hit, but my breakpoints are never hit. So for some reason the methods (any of the four) are never hit.
I also have a "DbCommandInterceptor" and a "SaveChangesInterceptor". Both of those work fine.
EF Core version: 8,0,2
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system: Windows 11 Pro
IDE: Visual Studio 2022 17.9.0 Preview 4
Reactions are currently unavailable