Closed Ponant closed 6 years ago
AddDefault uses a different set of apis, but does more or less the same thing except it removes roles functionality by default.
Roles is the only real difference between the two, they both return IdentityBuilders which can further customize identity.
@HaoK , I am happy to get rid of Roles, except that they seem to be generated in the sql db anyway. 1) 1) Why is that?
2) Could you be somewhat more precise on what you mean by "more or less"?
3) Why is
.AddDefaultTokenProviders();
not there anymore?
You can look at the differences here: https://github.com/aspnet/Identity/blob/c7276ce2f76312ddd7fccad6e399da96b9f6fae1/src/UI/IdentityServiceCollectionUIExtensions.cs#L49
It doesn't affect the migration, it just doesn't register any role services by default. Its not meant to replace any existing identity code.
This sugar is mostly for templates to use to collapse DefaultUI/DefaultTokenProviders
Sorry @HaoK , I did not fully understand your last post. My scenario is that I am not using the defaultUI, so do I need to add AddDefaultTokenProviders
to the pippleine if I use AddDefaultIdentity
, or is AddDefaultIdentity
already taking care of that? I stumbled upon the link you gave before writing this issue and it was not clear enough to me, sorry.
Oh @HaoK my deepest apologies , I misread the return value of AddDefaultIdentity.
It calls AddDefaultTokenProviders
.
All good
If you still need to use Roles you can do this:
services.AddDefaultIdentity<ApplicationUser>() .AddRoles<ApplicationRole>() .AddEntityFrameworkStores<MyApplicationContext>();
In scaffolding Identity I get this in ASP.NET Core 2.1:
Whereas the previous templates produced this
Which was clearer. Is is possible to understand the difference please? What does the former has that the latter does not? Can I just replace the former by the latter? Thanks