// <auto-generated />
using System;
using CarServiceDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

#nullable disable

namespace CarServiceDatabase.Migrations
{
    [DbContext(typeof(CarServiceDbContext))]
    [Migration("20230404184042_InitMigration")]
    partial class InitMigration
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "7.0.4")
                .HasAnnotation("Relational:MaxIdentifierLength", 128);

            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

            modelBuilder.Entity("CarServiceDatabase.Models.Customer", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<string>("Login")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Password")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Surname")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.HasKey("Id");

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

            modelBuilder.Entity("CarServiceDatabase.Models.Item", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<int>("Count")
                        .HasColumnType("int");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<decimal>("Price")
                        .HasColumnType("decimal (10,2)");

                    b.Property<int>("WorkerId")
                        .HasColumnType("int");

                    b.HasKey("Id");

                    b.HasIndex("WorkerId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.ItemForRepair", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<int>("Count")
                        .HasColumnType("int");

                    b.Property<int>("ItemId")
                        .HasColumnType("int");

                    b.Property<int>("RepairRequestId")
                        .HasColumnType("int");

                    b.HasKey("Id");

                    b.HasIndex("ItemId");

                    b.HasIndex("RepairRequestId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.RepairRequest", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<DateTime>("DateCreated")
                        .HasColumnType("datetime2");

                    b.Property<int>("VehicleId")
                        .HasColumnType("int");

                    b.HasKey("Id");

                    b.HasIndex("VehicleId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.Vehicle", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<int>("CustomerId")
                        .HasColumnType("int");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Plate")
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("VIN")
                        .HasColumnType("nvarchar(max)");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.Work", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<decimal>("Duration")
                        .HasColumnType("decimal (3,1)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<decimal>("Price")
                        .HasColumnType("decimal (10,2)");

                    b.Property<int>("WorkerId")
                        .HasColumnType("int");

                    b.HasKey("Id");

                    b.HasIndex("WorkerId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.WorkInRequest", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<decimal>("Cost")
                        .HasColumnType("decimal (10,2)");

                    b.Property<int>("Count")
                        .HasColumnType("int");

                    b.Property<int>("RepairRequestId")
                        .HasColumnType("int");

                    b.Property<int>("WorkId")
                        .HasColumnType("int");

                    b.HasKey("Id");

                    b.HasIndex("RepairRequestId");

                    b.HasIndex("WorkId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.WorkPayment", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<DateTime>("DatePayment")
                        .HasColumnType("datetime2");

                    b.Property<decimal>("Sum")
                        .HasColumnType("decimal (10,2)");

                    b.Property<int>("WorkInRequestId")
                        .HasColumnType("int");

                    b.HasKey("Id");

                    b.HasIndex("WorkInRequestId");

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

            modelBuilder.Entity("CarServiceDatabase.Models.Worker", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<string>("Login")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Password")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Surname")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.HasKey("Id");

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

            modelBuilder.Entity("CarServiceDatabase.Models.Item", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.Worker", "Worker")
                        .WithMany("Items")
                        .HasForeignKey("WorkerId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Worker");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.ItemForRepair", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.Item", "Item")
                        .WithMany("ItemsForRepair")
                        .HasForeignKey("ItemId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CarServiceDatabase.Models.RepairRequest", "RepairRequest")
                        .WithMany("ItemsForRepair")
                        .HasForeignKey("RepairRequestId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Item");

                    b.Navigation("RepairRequest");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.RepairRequest", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.Vehicle", "Vehicle")
                        .WithMany("RepairRequests")
                        .HasForeignKey("VehicleId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Vehicle");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Vehicle", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.Customer", "Customer")
                        .WithMany("Vehicles")
                        .HasForeignKey("CustomerId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Customer");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Work", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.Worker", "Worker")
                        .WithMany("Works")
                        .HasForeignKey("WorkerId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Worker");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.WorkInRequest", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.RepairRequest", "RepairRequest")
                        .WithMany("WorksInRequest")
                        .HasForeignKey("RepairRequestId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CarServiceDatabase.Models.Work", "Work")
                        .WithMany("WorksInRequest")
                        .HasForeignKey("WorkId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("RepairRequest");

                    b.Navigation("Work");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.WorkPayment", b =>
                {
                    b.HasOne("CarServiceDatabase.Models.WorkInRequest", "WorkInRequest")
                        .WithMany("WorkPayments")
                        .HasForeignKey("WorkInRequestId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("WorkInRequest");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Customer", b =>
                {
                    b.Navigation("Vehicles");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Item", b =>
                {
                    b.Navigation("ItemsForRepair");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.RepairRequest", b =>
                {
                    b.Navigation("ItemsForRepair");

                    b.Navigation("WorksInRequest");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Vehicle", b =>
                {
                    b.Navigation("RepairRequests");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Work", b =>
                {
                    b.Navigation("WorksInRequest");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.WorkInRequest", b =>
                {
                    b.Navigation("WorkPayments");
                });

            modelBuilder.Entity("CarServiceDatabase.Models.Worker", b =>
                {
                    b.Navigation("Items");

                    b.Navigation("Works");
                });
#pragma warning restore 612, 618
        }
    }
}