help
Root Question Message
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid? PostId { get; set; }
public List<Tag> Tags { get; set; }
public List<Image> AttachedImages { get; set; }
[ForeignKey("Account")]
public Guid? OriginalPosterId { get; set; }
public Account? OriginalPoster { get; set; }
[ForeignKey("Account")]
public List<Guid> PostParticipantsIds { get; set; }
public virtual ICollection<Account> PostParticipants { get; set; }
[ForeignKey("Account")]
public List<Guid> UsersAttendingIds { get; set; }
public virtual ICollection<Account> UsersAttending { get; set; }
System.InvalidOperationException: 'There are multiple navigations in entity type 'Post' which are pointing to same set of properties 'Account' using a [ForeignKey] attribute: 'PostParticipantsIds', 'UsersAttendingIds'.'
[ForeignKey("Account")]
public List<Guid> PostParticipantsIds { get; set; }
virtual
s while you're at itclass Account
{
public required Guid Id { get; set; }
public List<Post> Participates { get; set; } = new();
public List<Post> AttendingPosts{ get; set; } = new();
}
class Post
{
public required Guid Id { get; set; }
public List<Tag> Tags { get; set; } = new();
public List<Image> Images { get; set; } = new();
public required Account OriginalPoster { get; set; }
public Guid OriginalPosterId { get; set; }
public List<Account> Participants { get; set; } = new();
public List<Account> AttendingUsers { get; set; } = new();
}
class Tag
{
public required Guid Id { get; set; }
public List<Post> Posts { get; set; } = new();
}
class Image
{
public required Guid Id { get; set; }
public required Post Post { get; set; }
}
builder.Entity<Post>(cfg => {
cfg.HasMany(p => p.Participants)
.WithMany(a => a.Participates);
cfg.HasMany(p => p.AttendingUsers)
.WithMany(a => a.AttendingPosts);
});