I am migrating an ASP.NET Core 1.0 application to ASP.NET Core 2.0.
In my startup I am configuring two identities:
services.AddIdentity
After looking through the ASP.NET Core source code on github, a second identity could be added using this extension method:
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Text;
namespace Whatever
{
public static class IdentityExtensions
{
public static IdentityBuilder AddSecondIdentity(
this IServiceCollection services)
where TUser : class
where TRole : class
{
services.TryAddScoped, UserValidator>();
services.TryAddScoped, PasswordValidator>();
services.TryAddScoped, PasswordHasher>();
services.TryAddScoped, RoleValidator>();
services.TryAddScoped>();
services.TryAddScoped, UserClaimsPrincipalFactory>();
services.TryAddScoped, AspNetUserManager>();
services.TryAddScoped, SignInManager>();
services.TryAddScoped, AspNetRoleManager>();
return new IdentityBuilder(typeof(TUser), typeof(TRole), services);
}
}
}