My Asp.Net MVC application is setup as follows. There are 4 projects in solution.
<
I resolved it with the help of itikhomi..Posting the final code..
ApplicationDbContext
public static ApplicationDbContext Create()
{
return new ApplicationDbContext("name=GEContext");
}
AccountController
public ApplicationUserManager UserManager {
get
{
if (System.Web.HttpContext.Current.Session["SchoolCode"] == null)
return _userManager ?? HttpContext.GetOwinContext().GetUserManager();
else
{
var appDbContext = ApplicationDbContext.Create(System.Web.HttpContext.Current.Session["SchoolCode"].ToString());//new ApplicationDbContext("name=GEContext", System.Web.HttpContext.Current.Session["SchoolCode"].ToString());
HttpContext.GetOwinContext().Set(appDbContext);
HttpContext.GetOwinContext().Set(new ApplicationUserManager(new UserStore(appDbContext)));
return HttpContext.GetOwinContext().GetUserManager();
}
}
private set
{
_userManager = value;
}
}