I have classes for building many to many relationships.
public class Chat { [Key] public Guid Id { get; set; } public ICollection<ApplicationUserChat> UserChats { get; set; } }public class ApplicationUserChat
{
[Required]
public string UserId { get; set; }
public ApplicationUser User { get; set; }public Guid ChatId { get; set; } public Chat Chat { get; set; }
}
public class ApplicationUser : IdentityUser
{
public ICollection<ApplicationUserChat> UserChats { get; set; }
}
For example, I have a user1 and user2
#c-sharp #entity-framework #.net #linq