// <auto-generated />
using System;
using FSecure.C3.WebController.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace FSecure.C3.WebController.Migrations
{
    [DbContext(typeof(C3WebAPIContext))]
    [Migration("20210108094828_Initial")]
    partial class Initial
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "2.1.14-servicing-32113");

            modelBuilder.Entity("FSecure.C3.WebController.Models.Agent", b =>
                {
                    b.Property<ulong>("AgentId")
                        .ValueGeneratedOnAdd();

                    b.Property<ulong>("BuildId");

                    b.Property<string>("Discriminator")
                        .IsRequired();

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

                    b.Property<bool>("IsActive");

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

                    b.HasKey("AgentId");

                    b.HasIndex("BuildId");

                    b.ToTable("Agents");

                    b.HasDiscriminator<string>("Discriminator").HasValue("Agent");
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Build", b =>
                {
                    b.Property<ulong>("BuildId")
                        .ValueGeneratedOnAdd();

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

                    b.Property<byte[]>("BroadcastKey");

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

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

                    b.Property<string>("Discriminator")
                        .IsRequired();

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

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

                    b.Property<byte[]>("PublicKey");

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

                    b.HasKey("BuildId");

                    b.ToTable("Builds");

                    b.HasDiscriminator<string>("Discriminator").HasValue("Build");
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Channel", b =>
                {
                    b.Property<ulong>("AgentId");

                    b.Property<ulong>("InterfaceId");

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

                    b.Property<ulong>("Hash");

                    b.Property<bool>("IsNegotiationChannel");

                    b.Property<bool>("IsReturnChannel");

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

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

                    b.HasKey("AgentId", "InterfaceId");

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

            modelBuilder.Entity("FSecure.C3.WebController.Models.Command", b =>
                {
                    b.Property<ulong>("Id")
                        .ValueGeneratedOnAdd();

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

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

                    b.Property<ulong>("GatewayAgentId");

                    b.Property<ulong?>("InterfaceId");

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

                    b.Property<ulong?>("RelayAgentId");

                    b.HasKey("Id");

                    b.HasIndex("GatewayAgentId");

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

            modelBuilder.Entity("FSecure.C3.WebController.Models.Connector", b =>
                {
                    b.Property<ulong>("AgentId");

                    b.Property<ulong>("InterfaceId");

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

                    b.Property<ulong>("Hash");

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

                    b.HasKey("AgentId", "InterfaceId");

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

            modelBuilder.Entity("FSecure.C3.WebController.Models.Note", b =>
                {
                    b.Property<int>("NoteId")
                        .ValueGeneratedOnAdd();

                    b.Property<ulong>("AgentId");

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

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

                    b.HasKey("NoteId");

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

            modelBuilder.Entity("FSecure.C3.WebController.Models.Peripheral", b =>
                {
                    b.Property<ulong>("AgentId");

                    b.Property<ulong>("InterfaceId");

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

                    b.Property<ulong>("Hash");

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

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

                    b.HasKey("AgentId", "InterfaceId");

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

            modelBuilder.Entity("FSecure.C3.WebController.Models.Route", b =>
                {
                    b.Property<ulong>("AgentId");

                    b.Property<ulong>("OutgoingInterface");

                    b.Property<ulong>("DestinationAgent");

                    b.Property<ulong>("ReceivingInterface");

                    b.Property<bool>("IsNeighbour");

                    b.HasKey("AgentId", "OutgoingInterface", "DestinationAgent", "ReceivingInterface");

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

            modelBuilder.Entity("FSecure.C3.WebController.Models.Gateway", b =>
                {
                    b.HasBaseType("FSecure.C3.WebController.Models.Agent");


                    b.ToTable("Gateway");

                    b.HasDiscriminator().HasValue("Gateway");
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Relay", b =>
                {
                    b.HasBaseType("FSecure.C3.WebController.Models.Agent");

                    b.Property<ulong>("GatewayAgentId");

                    b.HasIndex("GatewayAgentId");

                    b.ToTable("Relay");

                    b.HasDiscriminator().HasValue("Relay");
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.GatewayBuild", b =>
                {
                    b.HasBaseType("FSecure.C3.WebController.Models.Build");

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

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

                    b.ToTable("GatewayBuild");

                    b.HasDiscriminator().HasValue("GatewayBuild");
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.RelayBuild", b =>
                {
                    b.HasBaseType("FSecure.C3.WebController.Models.Build");

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

                    b.ToTable("RelayBuild");

                    b.HasDiscriminator().HasValue("RelayBuild");
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Agent", b =>
                {
                    b.HasOne("FSecure.C3.WebController.Models.Build", "Build")
                        .WithMany()
                        .HasForeignKey("BuildId")
                        .OnDelete(DeleteBehavior.Cascade);
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Channel", b =>
                {
                    b.HasOne("FSecure.C3.WebController.Models.Agent")
                        .WithMany("Channels")
                        .HasForeignKey("AgentId")
                        .OnDelete(DeleteBehavior.Cascade);
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Connector", b =>
                {
                    b.HasOne("FSecure.C3.WebController.Models.Gateway")
                        .WithMany("Connectors")
                        .HasForeignKey("AgentId")
                        .OnDelete(DeleteBehavior.Cascade);
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Peripheral", b =>
                {
                    b.HasOne("FSecure.C3.WebController.Models.Agent")
                        .WithMany("Peripherals")
                        .HasForeignKey("AgentId")
                        .OnDelete(DeleteBehavior.Cascade);
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Route", b =>
                {
                    b.HasOne("FSecure.C3.WebController.Models.Agent")
                        .WithMany("Routes")
                        .HasForeignKey("AgentId")
                        .OnDelete(DeleteBehavior.Cascade);
                });

            modelBuilder.Entity("FSecure.C3.WebController.Models.Relay", b =>
                {
                    b.HasOne("FSecure.C3.WebController.Models.Gateway")
                        .WithMany("Relays")
                        .HasForeignKey("GatewayAgentId")
                        .OnDelete(DeleteBehavior.Cascade);

                    b.OwnsOne("FSecure.C3.WebController.Models.HostInfo", "HostInfo", b1 =>
                        {
                            b1.Property<ulong>("RelayAgentId");

                            b1.Property<string>("ComputerName");

                            b1.Property<string>("Domain");

                            b1.Property<bool>("IsElevated");

                            b1.Property<uint>("OsBuildNumber");

                            b1.Property<uint>("OsMajorVersion");

                            b1.Property<uint>("OsMinorVersion");

                            b1.Property<byte>("OsProductType");

                            b1.Property<ushort>("OsServicePackMajor");

                            b1.Property<ushort>("OsServicePackMinor");

                            b1.Property<uint>("ProcessId");

                            b1.Property<string>("UserName");

                            b1.ToTable("Agent");

                            b1.HasOne("FSecure.C3.WebController.Models.Relay")
                                .WithOne("HostInfo")
                                .HasForeignKey("FSecure.C3.WebController.Models.HostInfo", "RelayAgentId")
                                .OnDelete(DeleteBehavior.Cascade);
                        });
                });
#pragma warning restore 612, 618
        }
    }
}
