mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
23 lines
724 B
C#
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);
|
|
}
|
|
} |