I am using identity 2.0 for my application and want to move the data functionalities to repository layer such as the following code:
public class ApplicationDbInitializer : DropCreateDatabaseIfModelChanges<ApplicationDbContext> {
protected override void Seed(ApplicationDbContext context) {
InitializeIdentityForEF(context);
base.Seed(context);
}
//Create User=Admin@Admin.com with password=Admin@123456 in the Admin role
public static void InitializeIdentityForEF(ApplicationDbContext db) {
var userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
var roleManager = HttpContext.Current.GetOwinContext().Get<ApplicationRoleManager>();
now the problem is HttpContext
doesn't live in the repository layer and you have to pass it to that layer. but even if you do that, the call should be coming from the Web
layer. yet you don't want to include userManager
in every call to other layers. any solution?