Files
Govor/Govor.Data/Configurations/MediaAttachmentsConfiguration.cs
T
2025-07-11 21:52:37 +07:00

23 lines
724 B
C#

using Govor.Core.Models.Messages;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Govor.Data.Configurations;
public class MediaAttachmentsConfiguration : IEntityTypeConfiguration<MediaAttachments>
{
public void Configure(EntityTypeBuilder<MediaAttachments> builder)
{
builder.HasKey(ma => ma.Id);
builder.HasOne(ma => ma.Message)
.WithMany(m => m.MediaAttachments)
.HasForeignKey(ma => ma.MessageId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(ma => ma.MediaFile)
.WithMany()
.HasForeignKey(ma => ma.MediaFileId)
.OnDelete(DeleteBehavior.Restrict);
}
}