This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2023_Kanban/NG_2023_Kanban.DataLayer/EntityConfiguration/CommentConfiguration.cs

32 lines
1,020 B
C#
Raw Permalink Normal View History

2023-05-15 20:45:16 +03:00
using NG_2023_Kanban.DataLayer.Entities;
2023-05-11 23:20:46 +03:00
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
2023-05-15 20:45:16 +03:00
namespace NG_2023_Kanban.DataLayer.EntityConfiguration
2023-05-11 23:20:46 +03:00
{
public class CommentConfiguration : IEntityTypeConfiguration<Comment>
{
public void Configure(EntityTypeBuilder<Comment> builder)
{
builder.HasIndex(x => x.Id);
builder.Property(x => x.Id).IsRequired();
builder.Property(x => x.Text).IsRequired();
builder.Property(x => x.Text).HasMaxLength(100);
builder
.HasOne(x => x.Sender)
.WithMany(x => x.Comments)
.HasForeignKey(x => x.SenderId)
2023-05-16 22:09:57 +03:00
.HasPrincipalKey(x => x.Id)
.OnDelete(DeleteBehavior.Restrict);
2023-05-11 23:20:46 +03:00
builder
.HasOne(x => x.Card)
.WithMany(x => x.Comments)
.HasForeignKey(x => x.CardId)
.HasPrincipalKey(x => x.Id);
}
}
}