你的位置: 码友网首页 / 资讯源列表 / Development With A Dot - Accessing the HttpContext from a DbContext

关于[Development With A Dot - Accessing the HttpContext from a DbContext]的摘要:

Sometimes it might be necessary to access the current HttpContext from inside a DbContext, namely, from inside the OnConfiguring or OnModelCreating methods. Why? Well, for once, because of multitenancy: we may want to be able to decide the connection string to use based on the requesting or the host's domain, the current user or some other request parameter. Here the internal dependency injection (Instance) can’t help, because it cannot be used inside these methods.

原文地址: https://weblogs.asp.net/ricardoperes/accessing-the-httpcontext-from-a-dbcontext

收录时间: 2020-04-15 浏览量: 1398 分类: ASP.NET Core

| 0 收藏 | 0