//---------------------------------------------------------------------------------------------
// 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 SalesOrderDetailConfig : IEntityTypeConfiguration<SalesOrderDetail>
    {
        public void Configure(EntityTypeBuilder<SalesOrderDetail> c)
        {
            c.ToTable("SalesOrderDetail", "Sales")
             .HasKey(e => e.SalesOrderDetailId);

            // configure relationships

            c.HasOne(e => e.SalesOrderObject)
             .WithMany(p => p.DetailObjectList)
             .HasForeignKey(e => e.SalesOrderId)
             .OnDelete(DeleteBehavior.Cascade);

            c.HasOne(e => e.SpecialOfferProductObject)
             .WithMany()
             .HasForeignKey(e => new { e.SpecialOfferId, e.ProductId });

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

            c.Property(e => e.SalesOrderDetailId)
             .HasColumnName("SalesOrderDetailID")
             .HasColumnType("int")
             .IsRequired()
             .ValueGeneratedOnAdd();

            c.Property(e => e.CarrierTrackingNumber)
             .HasColumnName("CarrierTrackingNumber")
             .HasColumnType("nvarchar")
             .HasMaxLength(25)
             .IsUnicode();

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

            c.Property(e => e.SpecialOfferId)
             .HasColumnName("SpecialOfferID")
             .HasColumnType("int")
             .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.UnitPriceDiscount)
             .HasColumnName("UnitPriceDiscount")
             .HasColumnType("money")
             .IsRequired();

            c.Property(e => e.LineTotal)
             .HasColumnName("LineTotal")
             .HasColumnType("numeric(38,6)")
             .IsRequired()
             .ValueGeneratedOnAddOrUpdate();

            c.Property(e => e.Rowguid)
             .HasColumnName("rowguid")
             .HasColumnType("uniqueidentifier")
             .IsRequired();

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

        }
    }
}