private static void CreateDatabase()
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <EfDateAndTimeOfDayModelContext>());
            using (EfDateAndTimeOfDayModelContext db = new EfDateAndTimeOfDayModelContext())
            {
                if (!db.DateTimes.Any())
                {
                    DateTime dt = new DateTime(2015, 12, 22);

                    IList <DateAndTimeOfDayModel> dateTimes = Enumerable.Range(1, 5).Select(i =>
                                                                                            new DateAndTimeOfDayModel
                    {
                        Id          = i,
                        Birthday    = dt.AddYears(i),
                        EndDay      = dt.AddDays(i),
                        DeliverDay  = i % 2 == 0 ? (DateTime?)null : dt.AddYears(5 - i),
                        PublishDay  = i % 2 != 0 ? (DateTime?)null : dt.AddMonths(5 - i),
                        CreatedTime = new TimeSpan(0, i, 3, 5, 79),
                        EndTime     = i % 2 == 0 ? (TimeSpan?)null : new TimeSpan(0, 10 + i, 3 + i, 5 + i, 79 + i),
                        ResumeTime  = new TimeSpan(0, 8, 6, 4, 3)
                    }).ToList();

                    foreach (var efDateTime in dateTimes)
                    {
                        db.DateTimes.Add(efDateTime);
                    }

                    db.SaveChanges();
                }
            }
        }
        private static void CreateDatabase()
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<EfDateAndTimeOfDayModelContext>());
            using (EfDateAndTimeOfDayModelContext db = new EfDateAndTimeOfDayModelContext())
            {
                if (!db.DateTimes.Any())
                {
                    DateTime dt = new DateTime(2015, 12, 22);

                    IList<DateAndTimeOfDayModel> dateTimes = Enumerable.Range(1, 5).Select(i =>
                        new DateAndTimeOfDayModel
                        {
                            Id = i,
                            Birthday = dt.AddYears(i),
                            EndDay = dt.AddDays(i),
                            DeliverDay = i % 2 == 0 ? (DateTime?)null : dt.AddYears(5 - i),
                            PublishDay = i % 2 != 0 ? (DateTime?)null : dt.AddMonths(5 - i),
                            CreatedTime = new TimeSpan(0, i, 3, 5, 79),
                            EndTime = i % 2 == 0 ? (TimeSpan?)null : new TimeSpan(0, 10 + i, 3 + i, 5 + i, 79 + i),
                            ResumeTime = new TimeSpan(0, 8, 6, 4, 3)
                        }).ToList();

                    foreach (var efDateTime in dateTimes)
                    {
                        db.DateTimes.Add(efDateTime);
                    }

                    db.SaveChanges();
                }
            }
        }