//---------------------------------------------------------------------------------------------
// 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 BusinessEntityAddressConfig : IEntityTypeConfiguration<BusinessEntityAddress>
    {
        public void Configure(EntityTypeBuilder<BusinessEntityAddress> c)
        {
            c.ToTable("BusinessEntityAddress", "Person")
             .HasKey(e => new { e.BusinessEntityId, e.AddressId, e.AddressTypeId });

            // configure relationships

            c.HasOne(e => e.BusinessEntityObject)
             .WithMany()
             .HasForeignKey(e => e.BusinessEntityId);

            c.HasOne(e => e.AddressObject)
             .WithMany()
             .HasForeignKey(e => e.AddressId);

            c.HasOne(e => e.AddressTypeObject)
             .WithMany()
             .HasForeignKey(e => e.AddressTypeId);

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

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

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

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

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

        }
    }
}