How to fix System.InvalidOperationException: Scheme already exists: Identity.Application
By FoxLearn 6/17/2024 7:03:02 AM 453
The error message System.InvalidOperationException: Scheme already exists: Identity.Application
typically occurs when you're trying to add Identity to your ASP.NET Core project, but the scheme "Identity.Application" is already registered in the authentication options.
If you create an ApplicationUser
class that extends the IdentityUser class, then add a FullName
property
public class ApplicationUser : IdentityUser { public string FullName { get; set; } }
Here are a few steps you can take to resolve this issue:
Opening your Startup
class, then modify your class as shown below.
// already exists: identity.application scheme services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders();
Make sure you haven't accidentally configured Identity multiple times in your Startup.cs
file. Check for duplicate calls to services.AddIdentity
or any other related methods.
If you find duplicate configurations related to Identity in your Startup.cs
, remove the redundant ones.
- Getting Started with ASP.NET Core 3.0
- How to fix 'Authorization in ASP.NET Core' with 401 Unauthorized
- The name 'Session' does not exist in the current context
- How to create a Toast Notifications in ASP.NET Core
- How to Minify HTML using WebMarkupMin in ASP.NET Core
- How to fix 'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson'
- How to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'
- How to fix Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing