27 lines
777 B
C#
27 lines
777 B
C#
using Domain;
|
|
using Infrastructure.Identity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Infrastructure.EntityTypes
|
|
{
|
|
public class CommentEntityType : IEntityTypeConfiguration<Comment>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Comment> builder)
|
|
{
|
|
builder.HasKey(o => o.Id);
|
|
builder.Property(o => o.Content).IsRequired();
|
|
builder.Property(o => o.CreatedAt).IsRequired();
|
|
builder.HasOne<Link>()
|
|
.WithMany()
|
|
.HasForeignKey(o => o.LinkId)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
builder.HasOne<User>()
|
|
.WithMany()
|
|
.HasForeignKey(o => o.CreatedBy)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|
|
} |