//---------------------------------------------------------------------------------------------
// This file was AUTO-GENERATED by "EF Domain Objects" Xomega.Net generator.
//
// Manual CHANGES to this file WILL BE LOST when the code is regenerated.
//---------------------------------------------------------------------------------------------

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace AdventureWorks.Services.Entities
{
    public class PurchaseOrderDetailConfig : IEntityTypeConfiguration<PurchaseOrderDetail>
    {
        public void Configure(EntityTypeBuilder<PurchaseOrderDetail> c)
        {
            c.ToTable("PurchaseOrderDetail", "Purchasing")
             .HasKey(e => new { e.PurchaseOrderId, e.PurchaseOrderDetailId });

            // configure relationships

            c.HasOne(e => e.PurchaseOrderObject)
             .WithMany()
             .HasForeignKey(e => e.PurchaseOrderId);

            c.HasOne(e => e.ProductObject)
             .WithMany()
             .HasForeignKey(e => e.ProductId);

            // configure properties
          
            c.Property(e => e.PurchaseOrderId)
             .HasColumnName("PurchaseOrderID")
             .HasColumnType("int")
             .IsRequired();

            c.Property(e => e.PurchaseOrderDetailId)
             .HasColumnName("PurchaseOrderDetailID")
             .HasColumnType("int")
             .IsRequired()
             .ValueGeneratedOnAdd();

            c.Property(e => e.DueDate)
             .HasColumnName("DueDate")
             .HasColumnType("datetime")
             .IsRequired();

            c.Property(e => e.OrderQty)
             .HasColumnName("OrderQty")
             .HasColumnType("smallint")
             .IsRequired();

            c.Property(e => e.ProductId)
             .HasColumnName("ProductID")
             .HasColumnType("int")
             .IsRequired();

            c.Property(e => e.UnitPrice)
             .HasColumnName("UnitPrice")
             .HasColumnType("money")
             .IsRequired();

            c.Property(e => e.LineTotal)
             .HasColumnName("LineTotal")
             .HasColumnType("money")
             .IsRequired()
             .ValueGeneratedOnAddOrUpdate();

            c.Property(e => e.ReceivedQty)
             .HasColumnName("ReceivedQty")
             .HasColumnType("decimal(8,2)")
             .IsRequired();

            c.Property(e => e.RejectedQty)
             .HasColumnName("RejectedQty")
             .HasColumnType("decimal(8,2)")
             .IsRequired();

            c.Property(e => e.StockedQty)
             .HasColumnName("StockedQty")
             .HasColumnType("decimal(9,2)")
             .IsRequired()
             .ValueGeneratedOnAddOrUpdate();

            c.Property(e => e.ModifiedDate)
             .HasColumnName("ModifiedDate")
             .HasColumnType("datetime")
             .IsRequired();

        }
    }
}