Below is the IdentityUser subclass, and a simple entity. How can the IdentityUser be referenced within the Entity class? This application is using Entity Framework Core.
ApplicationUser.cs
using Microsoft.AspNetCore.Identity;
namespace MyProject.Models
{
public class ApplicationUser : IdentityUser
{
}
}
Entity.cs
namespace MyProject.Models
{
public class Entity
{
public int EntityId { get; set; }
/* What belongs here to associate to a user? */
}
}
The convention-over-configuration way would be:
public class Entity
{
public int EntityId { get; set; }
public string ApplicationUserId { get; set; }
public ApplicationUser ApplicationUser { get; set; }
}
And the following is optional, you can omit it if you don't need to get all Entities
for an user.
public class ApplicationUser : IdentityUser
{
public ICollection<Entity> Entities { get; set; }
}