예제 #1
0
        //Ensure populated method to automatically migrate pending migrations
        //and populate database with appointment if none exist
        public static void EnsurePopulated(IApplicationBuilder application)
        {
            ToursDbContext context = application.ApplicationServices.CreateScope()
                                     .ServiceProvider.GetRequiredService <ToursDbContext>();

            if (context.Database.GetPendingMigrations().Any())
            {
                context.Database.Migrate();
            }
            if (!context.Appointments.Any())
            {
                context.Appointments.AddRange(
                    new Appointment
                {
                    GroupName = "Cole Family",
                    GroupSize = 6,
                    Email     = "*****@*****.**",
                    Phone     = "801-555-5555"
                });
            }
        }
예제 #2
0
 //Class constructor
 public EFTourRepository(ToursDbContext context)
 {
     _context = context;
 }