EntityFrameworkCore - How to inject IPrincipal when DbContextPool is enabled
问题 I have an aspnet core MVC application, and I need to inject the IPrincipal of the current request so that I know who is the current logged in user. I followed this article with no problem. Now I need the IPrincipal in my Dbcontext to auto-populate audit fields (CreatedBy, UpdatedBy, etc). Being naive I could inject the IPrincipal in my DbContext constructor: public MyDBContext(DbContextOptions<MyDBContext> options, IPrincipal principal) But I am using the DBContextPool , which reuses