using DevExpress.ExpressApp.EF.Updating;
using DevExpress.Persistent.BaseImpl.EF;
using System;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;

// namespaces...
namespace  EntityFirst.Module.BusinessObjects
{
    // public classes...
    [DbConfigurationType(typeof(CustomDbConfiguration))]
    public class EntityFirstDbContext : DbContext
    {
        // public constructors...
        public EntityFirstDbContext()
            : base("name=ConnectionString")
        {
        }
		public EntityFirstDbContext(String connectionString)
            : base(connectionString)
        {
        }
		public EntityFirstDbContext(DbConnection connection)
            : base(connection, false)
        {
        }

        // public properties...
        public DbSet<Empl_work_dates> Empl_work_dates { get; set; }
        public DbSet<Employee> Employee { get; set; }
        public DbSet<EmployeeTransactions> EmployeeTransactions { get; set; }
        public DbSet<ModuleInfo> ModulesInfo { get; set; }
        public DbSet<ReportDataV2> Reports { get; set; }
        public DbSet<TaxAuthority> TaxAuthority { get; set; }
        // protected methods...
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.HasDefaultSchema("dbo");
            modelBuilder.Configurations.Add(new TaxAuthorityMap());
            modelBuilder.Configurations.Add(new EmployeeTransactionsConfiguration());
            modelBuilder.Configurations.Add(new Empl_work_datesConfiguration());
            modelBuilder.Configurations.Add(new EmployeeConfiguration());

            var conv = new AttributeToTableAnnotationConvention<TenantAwareAttribute, string>(
                    TenantAwareAttribute.TenantAnnotation, (type, attributes) => attributes.Single().ColumnName);

            modelBuilder.Conventions.Add(conv);
        }
	}
}