0

I have Application User which inherits from Identity User

    public class ApplicationUser : IdentityUser
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string IDNumber { get; set; }
        public string PhysicalAddress { get; set; }
    }

and Another VendorUser which inherits from ApplicationUser

    public class VendorUser : ApplicationUser
    {
        public int? VendorUserId { get; set; }
        public int CardNumber { get; set; }
        public string PhotoIDUrl { get; set; }
    }

If I Register the services in the startup.cs file like:

services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<AppDbContext>();
services.AddIdentity<VendorUser, IdentityRole>().AddEntityFrameworkStores<AppDbContext>();

I got the error above.

If its unable to resolve the service of the VendorUser if I don't. How do I resolve the service of the VendorUser without getting that error

Paul Gudu
  • 363
  • 1
  • 3
  • 10
  • Could you please share the details AppDbContext? Do you create two table one for ApplicationUser and another for VendorUser ? – Brando Zhang Sep 28 '20 at 09:28

1 Answers1

0

You cannot repeatedly use AddIdentity to add an identity.

ASP.NET Core provides a built-in method:AddIdentityCore<TUser>

You can use it like this:

 services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>();
 services.AddIdentityCore<VendorUser>().AddEntityFrameworkStores<ApplicationDbContext>();

Hope this can help you.

Yinqiu
  • 6,609
  • 1
  • 6
  • 14