I am currently using DI for my context like below.
services.AddTransient<APDatabase.DBContext>(provider =>
{
return new APDatabase.DBContext();
});
Is it possible to pass the current logged in user into this? I currently get the user in the controller as follows.
public NavigationController(APDatabase.DBContext context, IHttpContextAccessor httpContextAccessor)
{
this._context = context;
this._currentUser = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
}
I could then set this as a property on the context in the contsructor of each controller. This is the only way I can see of doing this currently but would prefer to have the DI handle it for me if possible.