public SimpleMembershipInitializer()
            {
                Database.SetInitializer<UsersContext>(null);

                try
                {
                    using (var context = new UsersContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                   // WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
        public JsonResult Login(LoginRegisterViewModel viewmodel)
        {
            UsersContext db = new UsersContext();
            bool res = true;

            LoginModel model = new LoginModel();
            model = Mapper.Map<LoginRegisterViewModel, LoginModel>(viewmodel);
               // return Json(viewmodel, JsonRequestBehavior.AllowGet);

            if (WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {

                var user = db.UserProfiles.Where(x => x.UserName.Equals(model.UserName)).First();
                int UserID = user.UserId;

                return Json(new { success = res, userData = user }, JsonRequestBehavior.AllowGet);
            }
            bool UserExists = db.UserProfiles.Any(x => x.UserName.Equals(model.UserName));
            if (UserExists)

                // If we got this far, something failed, redisplay form
                // ModelState.AddModelError("", "The user name or password provided is incorrect.");
                return Json(new { success = res, msg = "The user name or password provided is incorrect." }, JsonRequestBehavior.AllowGet);
            else
                //ModelState.AddModelError("", "There is no account with that UserName. Please sign up");
                return Json(new { success = res, msg = "There is no account with that UserName. Please sign up" }, JsonRequestBehavior.AllowGet);

            return Json(res, JsonRequestBehavior.AllowGet);
        }