'IdentityRole' Does not contain a definiton for 'Claims' accepting a first argument of type 'IdentityRole' could not be found? RRS feed

  • Question

  • I use to have this before upgrading my application to .NET Core 2.0 and IdentityServer 4.

    var role = new IdentityRole("Admin");
    role.Claims.Add(new IdentityRoleClaim<string> { ClaimType = "IsAdmin", ClaimValue = "True" });

    This no longer works, I tried Google, but couldn't see anything clear. The exact error is:


    How can I add a claim to IdentityRole with IdentityServer 4?

    Saturday, December 30, 2017 8:48 PM


  • Hi Sajeetharan s

    Thank you for posting here.

    For your question, I test the code you provided in .Net Core 2.0 console application. I do not get the same exception as yours.

    When I copy the code in my .net core console application. I get the exception below.

    I installed Microsoft.AspNet.Identity.AspNetCoreCompat from NuGet. And then I could add reference of Microsoft.AspNet.Identity.AspNetCoreCompat.

    After that, I get the exception as image below.

    After installed Microsoft.AspNet.Identity.EntityFramework, I fixed the all compiler errors.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 1, 2018 7:21 AM