Files
Govor/Govor.Data/Configurations/FriendshipConfiguration.cs
T
2026-03-01 16:48:06 +07:00

26 lines
799 B
C#

using Govor.Core.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Govor.Data.Configurations;
public class FriendshipConfiguration : IEntityTypeConfiguration<Friendship>
{
public void Configure(EntityTypeBuilder<Friendship> builder)
{
builder.HasKey(f => f.Id);
builder.HasOne(f => f.Requester)
.WithMany(u => u.SentFriendRequests)
.HasForeignKey(f => f.RequesterId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Addressee)
.WithMany(u => u.ReceivedFriendRequests)
.HasForeignKey(f => f.AddresseeId)
.OnDelete(DeleteBehavior.Restrict);
builder.Property(f => f.Status)
.IsRequired();
}
}