播种时,App.Run无法正常工作

时间:2017-12-20 04:19:08

标签: c# asp.net-core

我得到的是#HTTP; HTTP ERROR 404"尝试在启动时为默认用户和角色设定种子时出错。但是,如果我删除了播种代码,它就可以正常工作。

有什么想法让它有用吗?

public async void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services, 
    ILoggerFactory loggerFactory, IIdentitySeed storageSeed)   
{  
    // [...]

    IServiceScopeFactory scopeFactory = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>();

    using (IServiceScope scope = scopeFactory.CreateScope())
    {
        UserManager<ApplicationUser> userManager =
                scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
        RoleManager<ElCamino.AspNetCore.Identity.AzureTable.Model.IdentityRole> roleManager =
                scope.ServiceProvider.GetRequiredService<RoleManager<ElCamino.AspNetCore.Identity.AzureTable.Model.IdentityRole>>();

        await storageSeed.Seed(userManager, roleManager,
                app.ApplicationServices.GetService<IOptions<ApplicationSettings>>());
        }

    app.Run(services.GetRequiredService<SpaFallback>().RequestDelegate);
}

0 个答案:

没有答案