Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Why can't I use "Include" in extended primary key only in IdentityUser?

$
0
0

I extended only my IdentityUser class as below, Now I am trying to use include for my query to get all users and their roles but I keep receiving this error,

The property 'RoleId' is not a navigation property of entity type 'IdentityUserRole<string>'

My Extended IdentityUser class,

public class ApplicationUser :IdentityUser
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        [Display(Name = "Social Security Number")]
        public string SocialSecurityNo { get; set; }
        public string ContactAddress { get; set; }
        [StringLength(10)]
        public string StreetNo { get; set; }
        [StringLength(100)]
.......

And I am trying to do something like,

        [HttpGet]
        public async Task<IActionResult> GetUsersList()
        {
]            var test = await context.UserRoles
                            .Include(x=>x.RoleId)
                            .ToListAsync();

            return Ok(test);

        }


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>