// <auto-generated />
using System;
using GreenTree.Strohrmann.ERP.Domain.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace GreenTree.Strohrmann.ERP.Domain.Migrations
{
    [DbContext(typeof(ERPDbContext))]
    [Migration("20200721120025_Calculation")]
    partial class Calculation
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "3.1.5")
                .HasAnnotation("Relational:MaxIdentifierLength", 64);

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Craft", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("ChangedBy")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime?>("ChangedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime>("CreatedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<DateTime>("CreationDate")
                        .HasColumnType("datetime(6)");

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

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.CraftEmployee", b =>
                {
                    b.Property<int>("CraftId")
                        .HasColumnType("int");

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

                    b.Property<decimal>("Amount")
                        .HasColumnType("decimal(65,30)");

                    b.Property<decimal>("Value")
                        .HasColumnType("decimal(65,30)");

                    b.HasKey("CraftId", "EmployeeId");

                    b.HasIndex("EmployeeId");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.CraftMaterial", b =>
                {
                    b.Property<int>("CraftId")
                        .HasColumnType("int");

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

                    b.Property<decimal>("Amount")
                        .HasColumnType("decimal(65,30)");

                    b.Property<decimal>("CalculationFactor")
                        .HasColumnType("decimal(65,30)");

                    b.HasKey("CraftId", "MaterialId");

                    b.HasIndex("MaterialId");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Customer", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("Address")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("ChangedBy")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime?>("ChangedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("CompanyName")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Country")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime>("CreatedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("Firstname")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<bool>("IsBusiness")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("tinyint(1)")
                        .HasDefaultValue(false);

                    b.Property<string>("Lastname")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<int?>("TaxId")
                        .HasColumnType("int");

                    b.Property<string>("Town")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("ZipCode")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.HasKey("Id");

                    b.HasIndex("TaxId");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Employee", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<DateTime?>("Birthdate")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("ChangedBy")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime?>("ChangedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime>("CreatedOn")
                        .HasColumnType("datetime(6)");

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

                    b.Property<string>("Firstname")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Lastname")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("MailAddress")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.HasKey("Id");

                    b.HasIndex("EmployeeDegreeId");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.EmployeeDegree", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

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

                    b.Property<decimal>("Value")
                        .HasColumnType("decimal(65,30)");

                    b.HasKey("Id");

                    b.ToTable("EmployeeDegrees");

                    b.HasData(
                        new
                        {
                            Id = 1,
                            Name = "Meister",
                            Order = 3,
                            Value = 60m
                        },
                        new
                        {
                            Id = 2,
                            Name = "Geselle",
                            Order = 2,
                            Value = 30m
                        },
                        new
                        {
                            Id = 3,
                            Name = "Aushilfe",
                            Order = 1,
                            Value = 15m
                        });
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Material", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("ChangedBy")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime?>("ChangedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime>("CreatedOn")
                        .HasColumnType("datetime(6)");

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

                    b.Property<decimal>("Depth")
                        .HasColumnType("decimal(65,30)");

                    b.Property<string>("Description")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<decimal>("Height")
                        .HasColumnType("decimal(65,30)");

                    b.Property<string>("ItemNumber")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<decimal>("NetValue")
                        .HasColumnType("decimal(65,30)");

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

                    b.Property<decimal>("Width")
                        .HasColumnType("decimal(65,30)");

                    b.HasKey("Id");

                    b.HasIndex("DefaultUnitId");

                    b.HasIndex("SupplierId");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Supplier", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("Address")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("ChangedBy")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime?>("ChangedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("Comment")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Country")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<DateTime>("CreatedOn")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("Description")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("MailFirst")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("MailSecond")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("PhoneFirst")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("PhoneSecond")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Town")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("ZipCode")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.HasKey("Id");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Tax", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("ShortName")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<decimal>("Value")
                        .HasColumnType("decimal(65,30)");

                    b.HasKey("Id");

                    b.ToTable("Taxes");

                    b.HasData(
                        new
                        {
                            Id = 1,
                            Name = "Deutschland Umsatzsteuer",
                            ShortName = "Umst. (19%)",
                            Value = 0.19m
                        },
                        new
                        {
                            Id = 2,
                            Name = "Deutschland Umsatzsteuer 2020",
                            ShortName = "Umst. (16%) 2020",
                            Value = 0.16m
                        });
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Unit", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("Description")
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("ShortName")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.HasKey("Id");

                    b.ToTable("Units");

                    b.HasData(
                        new
                        {
                            Id = 8,
                            Description = "Angabe in Einheit Milimeter",
                            Name = "Milimeter",
                            ShortName = "mm"
                        },
                        new
                        {
                            Id = 1,
                            Description = "Angabe in Einheit Meter",
                            Name = "Meter",
                            ShortName = "m"
                        },
                        new
                        {
                            Id = 2,
                            Description = "Angabe in Einheit Quadratmeter",
                            Name = "Quadratmeter",
                            ShortName = "m²"
                        },
                        new
                        {
                            Id = 3,
                            Description = "Angabe in Einheit Kubikmeter",
                            Name = "Kubikmeter",
                            ShortName = "m³"
                        },
                        new
                        {
                            Id = 4,
                            Description = "Angabe in Einheit Liter",
                            Name = "Liter",
                            ShortName = "l"
                        },
                        new
                        {
                            Id = 5,
                            Description = "Angabe in Stückzahl",
                            Name = "Stück",
                            ShortName = "Stck."
                        },
                        new
                        {
                            Id = 6,
                            Description = "Angabe in Stückzahl",
                            Name = "Kilogramm",
                            ShortName = "Kg"
                        },
                        new
                        {
                            Id = 7,
                            Description = "Angabe in Zeitstunden",
                            Name = "Stunden",
                            ShortName = "Std."
                        });
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Rights.Policy", b =>
                {
                    b.Property<string>("Name")
                        .HasColumnType("varchar(255) CHARACTER SET utf8mb4");

                    b.HasKey("Name");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Rights.User", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    b.Property<string>("Accountname")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<bool?>("Activated")
                        .IsRequired()
                        .ValueGeneratedOnAdd()
                        .HasColumnType("tinyint(1)")
                        .HasDefaultValue(true);

                    b.Property<DateTime?>("Birthdate")
                        .HasColumnType("datetime(6)");

                    b.Property<string>("Forename")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Lastname")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("MailAddress")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.Property<string>("Password")
                        .IsRequired()
                        .HasColumnType("longtext CHARACTER SET utf8mb4");

                    b.HasKey("Id");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Rights.UserPolicy", b =>
                {
                    b.Property<int>("UserId")
                        .HasColumnType("int");

                    b.Property<string>("PolicyName")
                        .HasColumnType("varchar(255) CHARACTER SET utf8mb4");

                    b.HasKey("UserId", "PolicyName");

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

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Craft", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Customer", "Customer")
                        .WithMany("Crafts")
                        .HasForeignKey("CustomerId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.CraftEmployee", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Craft", "Craft")
                        .WithMany("CraftEmployees")
                        .HasForeignKey("CraftId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Employee", "Employee")
                        .WithMany()
                        .HasForeignKey("EmployeeId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.CraftMaterial", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Craft", "Craft")
                        .WithMany("CraftMaterials")
                        .HasForeignKey("CraftId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Material", "Material")
                        .WithMany()
                        .HasForeignKey("MaterialId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Customer", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Tax", "Tax")
                        .WithMany("Customers")
                        .HasForeignKey("TaxId")
                        .OnDelete(DeleteBehavior.Restrict);
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Employee", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.EmployeeDegree", "EmployeeDegree")
                        .WithMany("Employees")
                        .HasForeignKey("EmployeeDegreeId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Business.Material", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Unit", "DefaultUnit")
                        .WithMany("Materials")
                        .HasForeignKey("DefaultUnitId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Business.Supplier", "Supplier")
                        .WithMany("Materials")
                        .HasForeignKey("SupplierId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();
                });

            modelBuilder.Entity("GreenTree.Strohrmann.ERP.Core.Domain.Rights.UserPolicy", b =>
                {
                    b.HasOne("GreenTree.Strohrmann.ERP.Core.Domain.Rights.User", "User")
                        .WithMany("Policies")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });
#pragma warning restore 612, 618
        }
    }
}
