title: How can we create users with the same email but not the same workflow?
body: <p>I want to make it possible to create several users, even with the same email address as long as they do not have the same &quot;IdWorkflow&quot; number.</p>
  <p>But obviously it doesn't work... <code>result.Succeeded</code> is always false. &amp; all I have is that message : &quot;<em>User name 'test@test.com' is already taken.</em>&quot;</p>
  <p>What can I do...?</p>
  <p>Register.cshtml.cs</p>
  <pre class="lang-cs prettyprint-override"><code>if (ModelState.IsValid)
  {
      var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email, IdWorkflow = Input.IdWorkflow };
      var result = await _userManager.CreateAsync(user, Input.Password);
      if (result.Succeeded)
      {
          _logger.LogInformation(&quot;User created a new account with password.&quot;);
  
          var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
          code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
          var callbackUrl = Url.Page(
              &quot;/Account/ConfirmEmail&quot;,
              pageHandler: null,
              values: new { area = &quot;Identity&quot;, userId = user.Id, code = code, returnUrl = returnUrl },
              protocol: Request.Scheme);
  
          await _emailSender.SendEmailAsync(Input.Email, &quot;Confirm your email&quot;,
              $&quot;Please confirm your account by &lt;a href='{HtmlEncoder.Default.Encode(callbackUrl)}'&gt;clicking here&lt;/a&gt;.&quot;);
  
          if (_userManager.Options.SignIn.RequireConfirmedAccount)
          {
              return RedirectToPage(&quot;RegisterConfirmation&quot;, new { email = Input.Email, returnUrl = returnUrl });
          }
          else
          {
              await _signInManager.SignInAsync(user, isPersistent: false);
              return LocalRedirect(returnUrl);
          }
      }
      foreach (var error in result.Errors)
      {
          ModelState.AddModelError(string.Empty, error.Description);
      }
  }
  </code></pre>
  <p>AspNetUsers.sql</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE [dbo].[AspNetUsers] (
      [Id]                   NVARCHAR (450)     NOT NULL,
      [UserName]             NVARCHAR (256)     NULL,
      [NormalizedUserName]   NVARCHAR (256)     NULL,
      [Email]                NVARCHAR (256)     NULL,
      [NormalizedEmail]      NVARCHAR (256)     NULL,
      [EmailConfirmed]       BIT                NOT NULL,
      [PasswordHash]         NVARCHAR (MAX)     NULL,
      [SecurityStamp]        NVARCHAR (MAX)     NULL,
      [ConcurrencyStamp]     NVARCHAR (MAX)     NULL,
      [PhoneNumber]          NVARCHAR (MAX)     NULL,
      [PhoneNumberConfirmed] BIT                NOT NULL,
      [TwoFactorEnabled]     BIT                NOT NULL,
      [LockoutEnd]           DATETIMEOFFSET (7) NULL,
      [LockoutEnabled]       BIT                NOT NULL,
      [AccessFailedCount]    INT                NOT NULL,
      [DateCreate]           DATETIME2 (7)      DEFAULT ('0001-01-01T00:00:00.0000000') NOT NULL,
      [DateUpdate]           DATETIME2 (7)      DEFAULT ('0001-01-01T00:00:00.0000000') NOT NULL,
      [IdWorkflow]           NVARCHAR (450)     NULL,
      CONSTRAINT [PK_AspNetUsers] PRIMARY KEY CLUSTERED ([Id] ASC)
  );
  
  
  GO
  CREATE UNIQUE NONCLUSTERED INDEX [UserNameIndex]
      ON [dbo].[AspNetUsers]([NormalizedUserName] ASC, [IdWorkflow] ASC) WHERE ([NormalizedUserName] IS NOT NULL);
  
  
  </code></pre>