This may not be an โapprovedโ way of doing something, but I do.
The webpages_Membership table has an IsConfirmed field. Typically, this happens when you want to perform a two-step registration process: registration is activated via a link in an email. However, by its nature, this field has the same effect as IsApproved in the previous aspnet_Membership table: if set to true, the user can log in; if false, they cannot. So I just use plain old SQL to set true or false:
// If using EntityFramework // 1. Setup my params var params = new List<SqlParameter>() { new SqlParameter("@UserID", 1), new SqlParameter("@Activate", true) // or false }; SqlParameter[] paramArray = params.ToArray(); // 2. Update the database myDbContext.Database.ExecuteSqlCommand("UPDATE webpages_Membership SET IsConfirmed = @Activate WHERE UserId = @UserID", paramArray);
source share