using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.SqlServer;
using log4net;
using LeafWeb.Core.Entities;

namespace LeafWeb.Core.DAL
{
	public class LeafWebContext : DbContext
	{
		public DbSet<LeafInput> LeafInputs { get; set; }
		public DbSet<LeafInputFile> LeafInputFiles { get; set; }
		public DbSet<LeafInputStatus> LeafInputStatus { get; set; }
		public DbSet<FluxnetSite> FluxnetSites { get; set; }
		public DbSet<PhotosynthesisType> PhotosynthesisTypes { get; set; }
		public DbSet<LeafOutputFile> LeafOutputFiles { get; set; }
		public DbSet<LeafOutputFileContents> LeafOutputFileContents { get; set; }
		public DbSet<LeafInputData> LeafInputData { get; set; }
		public DbSet<LeafInputDataCurve> LeafInputDataCurves { get; set; }
		public DbSet<LeafInputDataPhotosynthetic> LeafInputDataPhotosynthetic { get; set; }
		public DbSet<LeafInputDataSite> LeafInputDataSite { get; set; }

		protected override void OnModelCreating(DbModelBuilder modelBuilder)
		{
			LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Debug("OnModelCreating");

			modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
			base.OnModelCreating(modelBuilder);
		}
	}

	public class LeafWebDbConfiguration : DbConfiguration
	{
		public LeafWebDbConfiguration()
		{
			SetExecutionStrategy("System.Data.SqlClient", () => new SqlAzureExecutionStrategy());
		}
	}
}
