myCustomDbContext' 无法转换为服务类型 'Microsoft.AspNetCore.Identity.IUserStore`1[erp_colombia.Entities.Employee]'
myCustomDbContext' can't be converted to service type 'Microsoft.AspNetCore.Identity.IUserStore`1[erp_colombia.Entities.Employee]'
我想制作 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>();
这是我的员工 class 的样子
[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>();
我想制作 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>();
这是我的员工 class 的样子
[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>();