22 lines
586 B
C#
22 lines
586 B
C#
using HN.Domain;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace HN.Infrastructure
|
|
{
|
|
public sealed class CommentEntityType : IEntityTypeConfiguration<Comment>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Comment> builder)
|
|
{
|
|
builder.ToTable("comments");
|
|
builder.HasKey(o => o.Id);
|
|
builder.HasOne<Link>()
|
|
.WithMany()
|
|
.HasForeignKey(o => o.LinkId)
|
|
.IsRequired();
|
|
builder.Property(o => o.Content).IsRequired();
|
|
builder.Property(o => o.CreatedAt).IsRequired();
|
|
}
|
|
}
|
|
|
|
} |