myCustomDbContext' 无法转换为服务类型 'Microsoft.AspNetCore.Identity.IUserStore`1[erp_colombia.Entities.Emp



我想创建IdentityDbContext并拥有一个自定义用户类型的员工。但当我启动应用程序时,我会收到这个错误

"ArgumentException: Implementation type 'erp_colombia.erp_colombiaDbContext' can't be converted to service type 'Microsoft.AspNetCore.Identity.IUserStore`1[erp_colombia.Entities.Employee]'"  How can I fix this problem thank you very much.

这是我的asp.net核心startup.cs文件中导致问题的一行。

services.AddIdentityCore<Employee>().AddUserStore<erp_colombiaDbContext>();

这是我的员工类的样子

[Table("erp_empleados")]
public class Employee : IdentityUser
{
public string Name { get; set; }
public string FamilyName { get; set; }
//AND MANY MORE FIELDS....    
}

以下是我的自定义dbContext看起来像

public class erp_colombiaDbContext : IdentityDbContext
{
public erp_colombiaDbContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
public DbSet<Employee> Employees { get; set; }
public DbSet<Menu> Menus { get; set; }
//ADD MANY MORE DbSets
}




我不得不更改

services.AddIdentityCore<Employee>().AddUserStore<erp_colombiaDbContext>();

services.AddIdentityCore<Employee>().AddEntityFrameworkStores<erp_colombiaDbContext>();

最新更新