
Explanation

Many-to-many relationships without an entity class to represent the join table are not yet supported. However, you can represent a many-to-many relationship by including an entity class for the join table and mapping two separate one-to-many relationships.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<PostTag>()
HasKey(t => new { t.PostId, t.TagId });
modelBuilder.Entity<PostTag>()
HasOne(pt => pt.Post)
WithMany(p => p.PostTags)
HasForeignKey(pt => pt.PostId);
modelBuilder.Entity<PostTag>()
HasOne(pt => pt.Tag)
WithMany(t => t.PostTags)
HasForeignKey(pt => pt.TagId);
}
}