using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GreenTree.Nachtragsmanagement.Data.Mapping.Site
{
    public class SiteMap : EntityTypeConfiguration<Core.Domain.Site.Site>
    {
        public SiteMap()
        {
            ToTable("Site");

            HasKey(s => s.Id);

            Property(s => s.CustomNumber);
            Property(s => s.Description);
            Property(s => s.Comment);
            Property(s => s.Start);
            Property(s => s.End);
            Property(s => s.Finished);

            HasMany(s => s.Users)
                .WithMany()
                .Map(m => m.ToTable("SiteUsers"));

            HasMany(s => s.Appendices)
                .WithOptional();

            HasMany(s => s.Deviations)
                .WithOptional();
        }
    }
}
