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

            // configure relationships

            c.HasOne(e => e.PersonObject)
             .WithMany()
             .HasForeignKey(e => e.PersonId);

            c.HasOne(e => e.StoreObject)
             .WithMany()
             .HasForeignKey(e => e.StoreId);

            c.HasOne(e => e.TerritoryObject)
             .WithMany()
             .HasForeignKey(e => e.TerritoryId);

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

            c.Property(e => e.PersonId)
             .HasColumnName("PersonID")
             .HasColumnType("int");

            c.Property(e => e.StoreId)
             .HasColumnName("StoreID")
             .HasColumnType("int");

            c.Property(e => e.TerritoryId)
             .HasColumnName("TerritoryID")
             .HasColumnType("int");

            c.Property(e => e.AccountNumber)
             .HasColumnName("AccountNumber")
             .HasColumnType("varchar")
             .HasMaxLength(10)
             .IsRequired()
             .ValueGeneratedOnAddOrUpdate();

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

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

        }
    }
}