Seeding related entities with EF

modelBuilder.Entity<Post>()
    .HasMany(p => p.Tags)
    .WithMany(t => t.Posts)
    .UsingEntity<Dictionary<string, object>>(
        "PostTag",
        r => r.HasOne<Tag>().WithMany().HasForeignKey("TagId"),
        l => l.HasOne<Post>().WithMany().HasForeignKey("PostId"),
        je =>
        {
            je.HasKey("PostId", "TagId");
            je.HasData(
                new { PostId = 1, TagId = "general" },
                new { PostId = 1, TagId = "informative" },
                new { PostId = 2, TagId = "classic" },
                new { PostId = 3, TagId = "opinion" },
                new { PostId = 4, TagId = "opinion" },
                new { PostId = 4, TagId = "informative" });
        }
    );

Source