【发布时间】:2021-07-02 14:47:04
【问题描述】:
您好,我在迁移时遇到问题,并且显示访问 Microsoft.Extensions.Hosting 服务时出现错误。在没有应用程序服务提供商的情况下继续。错误:某些服务无法构建(E
验证服务描述符“ServiceType:Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactory1[GraphQlApiFullStack.Models.AppUser] Lifetime: Scoped Implementati onType: Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory1[GraphQlApiFullStack.Models.AppUser]”时出错:无法解析类型“GraphQlApiFullStack.Data.ApplicationDbConte”的服务
xt 尝试激活 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore
谁能帮帮我,谢谢。
ApplicationDbContext.cs
using GraphQlApiFullStack.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace GraphQlApiFullStack.Data
{
public class ApplicationDbContext : IdentityDbContext<AppUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
public DbSet<AppUser> AppUsers { get; set; }
public DbSet<Employee> Employees { get; set; }
public DbSet<Department> Departments { get; set; }
}
}
Startup.cs 服务
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "GraphQlApiFullStack", Version = "v1" });
});
// We use a pooled Db Context Factory here to avoid issues with graphql concurrency
services.AddPooledDbContextFactory<ApplicationDbContext>(builder =>
{
builder.UseSqlServer(_configuration.GetConnectionString("defaultConnection"));
});
services.AddIdentityServices(_configuration);
}
```
【问题讨论】:
标签: c# entity-framework asp.net-core entity-framework-migrations