title: AddIdentity() fails "InvalidOperationException: Scheme already exists: Identity.Application"
body: <p>I'm trying to add facebook login to my .NET Core 2.1 site</p>
  <p>I'm following <a href="https://docs.microsoft.com/sv-se/aspnet/core/security/authentication/social/index?view=aspnetcore-2.1" rel="noreferrer">this</a> , guide and more specific, <a href="https://docs.microsoft.com/sv-se/aspnet/core/security/authentication/social/facebook-logins?view=aspnetcore-2.1&amp;tabs=aspnetcore2x" rel="noreferrer">this (for facebook login)</a></p>
  <p>After have adding the lines below to startup.cs, inside ConfigureServices-method</p>
  <pre class="lang-cs prettyprint-override"><code>public void ConfigureServices(IServiceCollection services)
  {
      ...
      services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddDefaultTokenProviders();
      ...
  }
  </code></pre>
  <p>I get the error message, when I'm running the application. Without these lines it works &quot;ok&quot;.  The user can login to facebook and approve my application and I get email and what not. BUT I'm guessing the user information will not be added to my database</p>
  <blockquote>
  <p><strong>InvalidOperationException: Scheme already exists: Identity.Application</strong>
  Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(string
  name, Action configureBuilder)...</p>
  </blockquote>
  <p>The code goes past the added lines and the error appears after a short while (during startup). I have searched in my project (which is just a bare .NET Core 2.1 Web application, from template) and I cant see any other usages of &quot;AddIdentity&quot;.</p>
  <p>I did find a &quot;AddDEfaultIdentity()&quot;, commented that line out. but then I got</p>
  <blockquote>
  <p><strong>InvalidOperationException: No service for type</strong>
  'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]'
  has been registered. Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)</p>
  </blockquote>