Beispiel #1
0
        private void MigrateDatabase(IApplicationBuilder app)
        {
            var genreConfiguration = Configuration.GetSection("Genre").Get <GenreConfiguration>();
            var userConfiguration  = Configuration.GetSection("User").Get <UserConfiguration>();
            var movieConfiguration = Configuration.GetSection("Movie").Get <MovieConfiguration>();
            //var movieGenreConfiguration = Configuration.GetSection("MovieGenre").Get<MovieGenreConfiguration>();
            var permissionConfiguration     = Configuration.GetSection("Permission").Get <PermissionConfiguration>();
            var reservationConfiguration    = Configuration.GetSection("Reservation").Get <ReservationConfiguration>();
            var roomConfiguration           = Configuration.GetSection("Room").Get <RoomConfiguration>();
            var roomPlanConfiguration       = Configuration.GetSection("RoomPlan").Get <RoomPlanConfiguration>();
            var scheduleConfiguration       = Configuration.GetSection("Schedule").Get <ScheduleConfiguration>();
            var scheduleSlotConfiguration   = Configuration.GetSection("ScheduleSlot").Get <ScheduleSlotConfiguration>();
            var seatTypeConfiguration       = Configuration.GetSection("SeatType").Get <SeatTypeConfiguration>();
            var seatPositionConfiguration   = Configuration.GetSection("SeatPosition").Get <SeatPositionConfiguration>();
            var locationConfiguration       = Configuration.GetSection("Location").Get <LocationConfiguration>();
            var roomAssignmentConfiguration = Configuration.GetSection("RoomAssignment").Get <RoomAssignmentConfiguration>();
            var roomTechnologyConfiguration = Configuration.GetSection("RoomTechnology").Get <RoomTechnologyConfiguration>();

            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <DatabaseContext>();
                context.Database.Migrate();

                GenreSeed.Seed(context, genreConfiguration.Genres);
                UserSeed.Seed(context, userConfiguration.Users);
                PermissionSeed.Seed(context, permissionConfiguration.Permissions);
                SeatTypeSeed.Seed(context, seatTypeConfiguration.SeatTypes);
                LocationSeed.Seed(context, locationConfiguration.Locations);
                RoomTechnologySeed.Seed(context, roomTechnologyConfiguration.RoomTechnologies);
            }
        }
Beispiel #2
0
        public void Configure(EntityTypeBuilder <Genre> builder)
        {
            builder.HasKey(p => p.Id);
            builder.HasIndex(p => p.Name).IsUnique();

            builder.HasData(GenreSeed.Seed());
        }
Beispiel #3
0
 private static void Seed(VideoStoreDbContext context)
 {
     context.Genres.AddRange(GenreSeed.Seed());
     context.Person.AddRange(PeopleSeed.Seed());
     context.ProductionCompanies.AddRange(ProductionCompanySeed.Seed());
     context.Movies.AddRange(MovieSeed.Seed());
     context.MovieGenre.AddRange(MovieGenreSeed.Seed());
     context.MovieActor.AddRange(MovieActorSeed.Seed());
     context.MovieDirector.AddRange(MovieDirectorSeed.Seed());
     context.MovieProductionCompany.AddRange(MovieProductionCompanySeed.Seed());
     context.SaveChanges();
 }