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

namespace Vrh.OneReport.Lib.Areas.OneReport.DbModels.Mapping
{
    public class LastSettingsSetMap : EntityTypeConfiguration<LastSettingsSet>
    {
        public LastSettingsSetMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.User)
                .IsRequired();

            this.Property(t => t.Query)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("LastSettingsSet");
            this.Property(t => t.User).HasColumnName("User");
            this.Property(t => t.Query).HasColumnName("Query");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.QuerySettings_Id).HasColumnName("QuerySettings_Id");

            // Relationships
            this.HasOptional(t => t.QuerySettingsSet)
                .WithMany(t => t.LastSettingsSets)
                .HasForeignKey(d => d.QuerySettings_Id);

        }
    }
}
