ShipCertificateEntityTypeConfiguration.cs 1.11 KB
Newer Older
PongpatApiratchatanond committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
using Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Infrastructure
{
    public class ShipCertificateEntityTypeConfiguration : IEntityTypeConfiguration<ShipCertificate>
    {
        public void Configure(EntityTypeBuilder<ShipCertificate> builder)
        {
            builder.ToTable("ShipCertificate");

            builder.HasKey(x => x.shipcertificatekey);

            builder.HasOne(s => s.Document).WithMany(g => g.ShipCertificate).HasForeignKey(s => s.documentkey);
            builder.HasOne(x => x.MyShip).WithMany(g => g.ShipCertificate).HasForeignKey(x => x.shipRegisterNoKey);

            builder.Property(x => x.shipcertificatekey).HasColumnName("shipcertificatekey");
            builder.Property(x => x.shipRegisterNoKey).HasColumnName("shipRegisterNoKey");
            builder.Property(x => x.documentkey).HasColumnName("documentkey");
            builder.Property(x => x.certificateno).HasColumnName("certificateno");
         
        }
    }
}