// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using System;
using TriathlonRaceTracking.Data;
using TriathlonRaceTracking.Models;

namespace TriathlonRaceTracking.Migrations
{
    [DbContext(typeof(TriathlonRaceTrackingContext))]
    [Migration("20171007204809_Initial")]
    partial class Initial
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "2.0.0-rtm-26452")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("TriathlonRaceTracking.Models.Athlete", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd();

                    b.Property<string>("FirstName");

                    b.Property<string>("LastName");

                    b.Property<string>("Nationality");

                    b.HasKey("ID");

                    b.ToTable("Athlete");
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.Race", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd();

                    b.Property<DateTime>("Date");

                    b.Property<string>("Location");

                    b.Property<string>("Name");

                    b.HasKey("ID");

                    b.ToTable("Race");
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.Registration", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd();

                    b.Property<int>("AthleteID");

                    b.Property<int>("BibNumber");

                    b.Property<int>("RaceID");

                    b.HasKey("ID");

                    b.HasIndex("AthleteID");

                    b.HasIndex("RaceID");

                    b.ToTable("Registration");
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.Timing", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd();

                    b.Property<int>("RegistrationID");

                    b.Property<DateTime>("Time");

                    b.Property<int>("TimingPointID");

                    b.HasKey("ID");

                    b.HasIndex("RegistrationID");

                    b.HasIndex("TimingPointID");

                    b.ToTable("Timing");
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.TimingPoint", b =>
                {
                    b.Property<int>("ID")
                        .ValueGeneratedOnAdd();

                    b.Property<string>("Code");

                    b.Property<string>("Name");

                    b.Property<int>("RaceID");

                    b.Property<int>("Type");

                    b.HasKey("ID");

                    b.HasIndex("RaceID");

                    b.ToTable("TimingPoint");
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.Registration", b =>
                {
                    b.HasOne("TriathlonRaceTracking.Models.Athlete", "Athlete")
                        .WithMany("Registrations")
                        .HasForeignKey("AthleteID")
                        .OnDelete(DeleteBehavior.Cascade);

                    b.HasOne("TriathlonRaceTracking.Models.Race", "Race")
                        .WithMany("Registrations")
                        .HasForeignKey("RaceID")
                        .OnDelete(DeleteBehavior.Cascade);
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.Timing", b =>
                {
                    b.HasOne("TriathlonRaceTracking.Models.Registration", "Registration")
                        .WithMany("Timings")
                        .HasForeignKey("RegistrationID")
                        .OnDelete(DeleteBehavior.Cascade);

                    b.HasOne("TriathlonRaceTracking.Models.TimingPoint", "TimingPoint")
                        .WithMany("Timings")
                        .HasForeignKey("TimingPointID")
                        .OnDelete(DeleteBehavior.Restrict);
                });

            modelBuilder.Entity("TriathlonRaceTracking.Models.TimingPoint", b =>
                {
                    b.HasOne("TriathlonRaceTracking.Models.Race", "Race")
                        .WithMany("TimingPoints")
                        .HasForeignKey("RaceID")
                        .OnDelete(DeleteBehavior.Cascade);
                });
#pragma warning restore 612, 618
        }
    }
}
