Beispiel #1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity <AvailableTickets>().HasData(Seed.AvailableTickets());

            var reservedTicketEntity = modelBuilder.Entity <ReservedTicket>();
            var reservationEntity    = modelBuilder.Entity <Reservation>();

            reservedTicketEntity
            .HasOne <Reservation>()
            .WithMany(r => r.ReservedTickets)
            .IsRequired()
            .HasForeignKey(so => so.ReservationId)
            .OnDelete(DeleteBehavior.Cascade);

            var orderedTicketEntity = modelBuilder.Entity <OrderedTicket>();
            var orderEntity         = modelBuilder.Entity <Order>();

            orderedTicketEntity
            .HasOne <Order>()
            .WithMany(r => r.OrderedTickets)
            .IsRequired()
            .HasForeignKey(so => so.OrderId)
            .OnDelete(DeleteBehavior.Cascade);

            base.OnModelCreating(modelBuilder);
        }