//---------------------------------------------------------------------------------------------
// 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 StateProvinceConfig : IEntityTypeConfiguration<StateProvince>
    {
        public void Configure(EntityTypeBuilder<StateProvince> c)
        {
            c.ToTable("StateProvince", "Person")
             .HasKey(e => e.StateProvinceId);

            // configure relationships

            c.HasOne(e => e.CountryRegionCodeObject)
             .WithMany()
             .HasForeignKey(e => e.CountryRegionCode);

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

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

            c.Property(e => e.StateProvinceCode)
             .HasColumnName("StateProvinceCode")
             .HasColumnType("nchar")
             .HasMaxLength(3)
             .IsUnicode()
             .IsFixedLength()
             .IsRequired();

            c.Property(e => e.CountryRegionCode)
             .HasColumnName("CountryRegionCode")
             .HasColumnType("nvarchar")
             .HasMaxLength(3)
             .IsUnicode()
             .IsRequired();

            c.Property(e => e.IsOnlyStateProvinceFlag)
             .HasColumnName("IsOnlyStateProvinceFlag")
             .HasColumnType("bit")
             .IsRequired();

            c.Property(e => e.Name)
             .HasColumnName("Name")
             .HasColumnType("nvarchar")
             .HasMaxLength(50)
             .IsUnicode()
             .IsRequired();

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

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

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

        }
    }
}