Im trying to add roles functionality to my app but I'm getting an error message that I don't really understand or know how to fix it.
Im trying to add The IdentityRole to services.AddIdentityCore but getting an error message:
"'IServiceCollection' does not contain a definition for 'AddIdentityCore' and no accessible extension method 'AddIdentityCore' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) [API]csharp(CS1061)
Does anyone know how to implement it right? What causes this issue ? Thanks so much for the help
CodePudding user response:
The solution is simple. Try this code like below:-
Your AppUser.cs
model:-
public class AppUser:IdentityUser
{
...
}
Your startup.cs
file:-
services.AddIdentity<AppUser, IdentityRole>(options=> {
options.Password.RequireDigit = false;
...
})
.AddEntityFrameworkStores<DataContext>()
.AddDefaultTokenProviders();
Try exact same code as above.It will resolve your issue.