using Lada.Framework.Data.Domains.Cms;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Lada.Framework.Data.Mappings.EntityMappings.Cms
{
    public class PostTagMap : IEntityMappingConfiguration<PostTag>
    {
        public void Map(EntityTypeBuilder<PostTag> builder)
        {
            builder.HasKey(pc => new { pc.PostId, pc.TagId });
            builder.HasOne(pc => pc.Post).WithMany(p => p.PostTags).HasForeignKey(pc => pc.PostId);
            builder.HasOne(pc => pc.Tag).WithMany(p => p.PostTags).HasForeignKey(pc => pc.TagId);
            builder.ToTable("PostTag");
        }
    }
}
