I upload an excel file containing all the necessary users to my site using ASP.NET Identity and OwinContext and EF 6. My code looks like this:
foreach (var bulkUserDetail in bulkUser.BulkUserDetails)
{
var userManager = owinContext.GetUserManager<ApplicationUserManager>();
var userProfile = new UserProfile();
userProfile.Username = bulkUserDetail.Username;
AspNetUser newUser = new AspNetUser
{
UserName = userProfile.Username,
Email = bulkUserDetail.Email,
LastPasswordChangedDate = null,
};
var creationResult = userManager.Create(newUser);
if (creationResult.Succeeded)
{
string token = userManager.GeneratePasswordResetToken(newUser.Id);
}
}
The problem is that the performance of the next two lines is pretty disappointing
userManager.Create(newUser) -- (900 milliseconds)
userManager.GeneratePasswordResetToken(newUser.Id) --(1800 milliseconds)
In large numbers, that is, 2,000 users, performance is becoming a serious problem. Is it better practice to speed up this process? I am open to suggestions, but I need to leave the OwinContext library.
Thanks in advance
source
share