2021-04-29 11:46:17 +02:00

22 lines
630 B
C#

using Domain;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.EntityTypes
{
public class LinkEntityType : IEntityTypeConfiguration<Link>
{
public void Configure(EntityTypeBuilder<Link> builder)
{
builder.HasKey(o => o.Id);
builder.Property(o => o.Url).HasMaxLength(250).IsRequired();
builder.Property(o => o.CreatedAt).IsRequired();
builder.HasOne<User>()
.WithMany()
.HasForeignKey(o => o.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.Cascade);
}
}
}