Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with trying to use multiple identities .net core 5.0 #46

Open
humzayunasnandla opened this issue Dec 22, 2021 · 0 comments
Open

Comments

@humzayunasnandla
Copy link

Hi everyone,

I am new to asp.net core and i started working on asp.net from version 5.0 core. I have switched to asp.net from laravel php framework. This was my brief introduction. I have been working on asp.net and using database first approach i built dbcontext and implemented my whole system in asp.net but in start i wanted to use identity scaffolding and use all commands that added a new identitydbcontext. So i have now two dbcontext one is asp.net core default with only identity and other is my database from db first approach.

I have implemented the default identity system by using

services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
                .AddRoles<IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>();

But after this i wanted to authenticate users against a custom model tblemployee with fields i.e phone and scale. But when i try to add this by using a method that I found here Asp.net core 2.0 multiple identity .

My code to do that is

services.AddIdentityCore<TblEmployee>().AddEntityFrameworkStores<DbBzuCCContext>().AddDefaultTokenProviders();

But the code is not working it says that extend from IdentityUser but i can't use identityuser fields in my model. I just want to use my 2 fields to work as additional identity provider. Is there any way in middle ware to change default route for different identity and all my previous controllers to be used from default identity but new one with other identity.

Any help will be highly appreciated.

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant