//---------------------------------------------------------------------------------------------
// 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 WorkOrderConfig : IEntityTypeConfiguration<WorkOrder>
    {
        public void Configure(EntityTypeBuilder<WorkOrder> c)
        {
            c.ToTable("WorkOrder", "Production")
             .HasKey(e => e.WorkOrderId);

            // configure relationships

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

            c.HasOne(e => e.ScrapReasonObject)
             .WithMany()
             .HasForeignKey(e => e.ScrapReasonId);

            // configure properties
          
            c.Property(e => e.WorkOrderId)
             .HasColumnName("WorkOrderID")
             .HasColumnType("int")
             .IsRequired()
             .ValueGeneratedOnAdd();

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

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

            c.Property(e => e.StockedQty)
             .HasColumnName("StockedQty")
             .HasColumnType("int")
             .IsRequired()
             .ValueGeneratedOnAddOrUpdate();

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

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

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

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

            c.Property(e => e.ScrapReasonId)
             .HasColumnName("ScrapReasonID")
             .HasColumnType("smallint");

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

        }
    }
}