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

namespace DAL
{
    public class DataBaseContext : DbContext
    {
        public DataBaseContext()
            : base("DefaultConnection")
        {
            Database.SetInitializer(new DataBaseInitializer());
        }

        public DbSet<Foo> Foos { get; set; }
        public DbSet<FooItem> FooItems { get; set; }
    }

    public class DataBaseInitializer : 
        DropCreateDatabaseIfModelChanges<DataBaseContext>
    {
        protected override void Seed(DataBaseContext context)
        {
            context.FooItems.Add(new FooItem() { ItemValue = "Item 01" });
            context.FooItems.Add(new FooItem() { ItemValue = "Item 02" });
            context.FooItems.Add(new FooItem() { ItemValue = "Item 03" });
            context.FooItems.Add(new FooItem() { ItemValue = "Item 04" });
            context.SaveChanges();
            base.Seed(context);
        }
    }
}
