A
A
AspMaster2019-09-29 18:29:03
ASP.NET
AspMaster, 2019-09-29 18:29:03

How to connect Identity for two entities at once in two contexts?

There is a code for connecting Identity:

services.AddIdentity<Customer, IdentityRole<Guid>>(o =>
            {
                o.Password.RequireNonAlphanumeric = false;
                o.Password.RequireUppercase = false;
                o.Password.RequireLowercase = false;
            })
                .AddEntityFrameworkStores<StoreContext>()
                .AddDefaultTokenProviders();

            services.AddIdentity<Manager, IdentityRole<Guid>>()
                .AddEntityFrameworkStores<ManagerContext>()
                .AddDefaultTokenProviders();

Obviously I'm getting the error:
InvalidOperationException: Scheme already exists: Identity.Application Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(string name, Action<AuthenticationSchemeBuilder> configureBuilder)

How can I connect Identity for two different entities that are in different contexts and different databases?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question