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("Recon", "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); } }
private void GetUserDetails() { var context = new UsersContext(); var username = User.Identity.Name; String[] role = Roles.GetRolesForUser(username); if (role.Count() == 0) { WebSecurity.Logout(); RedirectToAction("Error"); } _role = role[0]; if (this._role.Equals(RoleList.Country)) { UserProfileModel user = context.UserProfiles.SingleOrDefault(u => u.UserName == username); this._country = user.Country; } }