0

I have two databases 'ApplicationDbContext' for Admin and 'TenantDbContext' for client users. But my client now wants a feature to access other portals through his user from ApplicationDbContext.

I tried adding two Identities in the DI container but it throws an error in runtime saying 'Scheme already exists: Identity.Application'

The code I used is below:

services.AddIdentity<TenantUser, IdentityRole>()
                .AddEntityFrameworkStores<TenantDbContext>()
                .AddDefaultTokenProviders();
          
            services.AddIdentity<User, Data.Entities.ApplicationDbUsers.Role>(options =>
            {
            })
               .AddEntityFrameworkStores<ApplicationDbContext>()
               .AddDefaultTokenProviders();

Is there any way I can add two identities in Ioc Container so that I users can be authorized from both the databases?

Milad Dastan Zand
  • 1,086
  • 1
  • 10
  • 20
Rajon Tanducar
  • 150
  • 2
  • 7
  • Something like this maybe https://stackoverflow.com/questions/47433269/multiple-identities-in-asp-net-core-2-0 – arynaq Oct 26 '21 at 14:21

0 Answers0