0
我想根據用戶在登錄屏幕輸入的代碼在運行時更改我的連接字符串。我做了以下Owin ApplicationDbContext沒有更新
ApplicationDbContext
public static ApplicationDbContext Create(string scCode){
return new ApplicationDbContext("name=GEContext_" + scCode);
}
而且在登錄時我改變的ConnectionString如下
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (ModelState.IsValid)
{
try
{
System.Web.HttpContext.Current.Session["SchoolCode"] = model.SchoolCode;
var appDbContext = ApplicationDbContext.Create(model.SchoolCode);
HttpContext.GetOwinContext().Set<ApplicationDbContext>(appDbContext);
....
}
}
}
現在它仍然是指原始數據庫......我失去了什麼?
P.S.對於歷史/詳細考慮this post