Use enumerations in EF models.

This commit is contained in:
2018-08-06 21:07:07 +01:00
parent b9aca7a804
commit e6378588f3
12 changed files with 1805 additions and 73 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class UseExistingEnumerations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder) { }
protected override void Down(MigrationBuilder migrationBuilder) { }
}
}

View File

@@ -199,17 +199,17 @@ namespace Cicm.Database.Migrations
b.Property<int>("CompanyId").HasColumnName("company_id").HasColumnType("int(11)"); b.Property<int>("CompanyId").HasColumnName("company_id").HasColumnType("int(11)");
b.Property<string>("LogoGuid").HasColumnName("logo_guid").HasColumnType("char(36)"); b.Property<string>("Guid").HasColumnName("logo_guid").HasColumnType("char(36)");
b.Property<int?>("Year").HasColumnName("year").HasColumnType("int(4)"); b.Property<int?>("Year").HasColumnName("year").HasColumnType("int(4)");
b.HasKey("Id", "CompanyId", "LogoGuid"); b.HasKey("Id", "CompanyId", "Guid");
b.HasIndex("CompanyId").HasName("idx_company_id"); b.HasIndex("CompanyId").HasName("idx_company_id");
b.HasIndex("Id").IsUnique().HasName("idx_id"); b.HasIndex("Guid").HasName("idx_guid");
b.HasIndex("LogoGuid").HasName("idx_guid"); b.HasIndex("Id").IsUnique().HasName("idx_id");
b.ToTable("company_logos"); b.ToTable("company_logos");
}); });
@@ -938,7 +938,7 @@ namespace Cicm.Database.Migrations
modelBuilder.Entity("Cicm.Database.Models.CompanyDescriptions", modelBuilder.Entity("Cicm.Database.Models.CompanyDescriptions",
b => b =>
{ {
b.HasOne("Cicm.Database.Models.Companies", "Company").WithOne("CompanyDescriptions") b.HasOne("Cicm.Database.Models.Companies", "Company").WithOne("Description")
.HasForeignKey("Cicm.Database.Models.CompanyDescriptions", "Id") .HasForeignKey("Cicm.Database.Models.CompanyDescriptions", "Id")
.HasConstraintName("fk_company_id").OnDelete(DeleteBehavior.Cascade); .HasConstraintName("fk_company_id").OnDelete(DeleteBehavior.Cascade);
}); });

View File

@@ -16,24 +16,24 @@ namespace Cicm.Database.Models
SoundSynths = new HashSet<SoundSynths>(); SoundSynths = new HashSet<SoundSynths>();
} }
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public DateTime? Founded { get; set; } public DateTime? Founded { get; set; }
public string Website { get; set; } public string Website { get; set; }
public string Twitter { get; set; } public string Twitter { get; set; }
public string Facebook { get; set; } public string Facebook { get; set; }
public DateTime? Sold { get; set; } public DateTime? Sold { get; set; }
public int? SoldToId { get; set; } public int? SoldToId { get; set; }
public string Address { get; set; } public string Address { get; set; }
public string City { get; set; } public string City { get; set; }
public string Province { get; set; } public string Province { get; set; }
public string PostalCode { get; set; } public string PostalCode { get; set; }
public short? CountryId { get; set; } public short? CountryId { get; set; }
public int Status { get; set; } public CompanyStatus Status { get; set; }
public Iso31661Numeric Country { get; set; } public Iso31661Numeric Country { get; set; }
public Companies SoldTo { get; set; } public Companies SoldTo { get; set; }
public CompanyDescriptions CompanyDescriptions { get; set; } public CompanyDescriptions Description { get; set; }
public ICollection<CompanyLogos> CompanyLogos { get; set; } public ICollection<CompanyLogos> CompanyLogos { get; set; }
public ICollection<Gpus> Gpus { get; set; } public ICollection<Gpus> Gpus { get; set; }
public ICollection<Companies> InverseSoldToNavigation { get; set; } public ICollection<Companies> InverseSoldToNavigation { get; set; }

View File

@@ -5,7 +5,7 @@
public int Id { get; set; } public int Id { get; set; }
public int CompanyId { get; set; } public int CompanyId { get; set; }
public int? Year { get; set; } public int? Year { get; set; }
public string LogoGuid { get; set; } public string Guid { get; set; }
public Companies Company { get; set; } public Companies Company { get; set; }
} }

View File

@@ -14,13 +14,13 @@ namespace Cicm.Database.Models
Storage = new HashSet<StorageByMachine>(); Storage = new HashSet<StorageByMachine>();
} }
public int Id { get; set; } public int Id { get; set; }
public int CompanyId { get; set; } public int CompanyId { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int Type { get; set; } public MachineType Type { get; set; }
public DateTime? Introduced { get; set; } public DateTime? Introduced { get; set; }
public int? FamilyId { get; set; } public int? FamilyId { get; set; }
public string Model { get; set; } public string Model { get; set; }
public Companies Company { get; set; } public Companies Company { get; set; }
public MachineFamilies Family { get; set; } public MachineFamilies Family { get; set; }

View File

@@ -2,12 +2,12 @@
{ {
public class MemoryByMachine public class MemoryByMachine
{ {
public int MachineId { get; set; } public int MachineId { get; set; }
public int Type { get; set; } public MemoryType Type { get; set; }
public int Usage { get; set; } public MemoryUsage Usage { get; set; }
public long? Size { get; set; } public long? Size { get; set; }
public double? Speed { get; set; } public double? Speed { get; set; }
public long Id { get; set; } public long Id { get; set; }
public Machines Machine { get; set; } public Machines Machine { get; set; }
} }

View File

@@ -2,9 +2,9 @@
{ {
public class News public class News
{ {
public int Id { get; set; } public int Id { get; set; }
public string Date { get; set; } public string Date { get; set; }
public int Type { get; set; } public NewsType Type { get; set; }
public int AddedId { get; set; } public int AddedId { get; set; }
} }
} }

View File

@@ -2,23 +2,23 @@
{ {
public class OwnedComputers public class OwnedComputers
{ {
public int Id { get; set; } public int Id { get; set; }
public int DbId { get; set; } public int DbId { get; set; }
public string Date { get; set; } public string Date { get; set; }
public int Status { get; set; } public StatusType Status { get; set; }
public int Trade { get; set; } public int Trade { get; set; }
public int Boxed { get; set; } public int Boxed { get; set; }
public int Manuals { get; set; } public int Manuals { get; set; }
public int Cpu1 { get; set; } public int Cpu1 { get; set; }
public decimal Mhz1 { get; set; } public decimal Mhz1 { get; set; }
public int Cpu2 { get; set; } public int Cpu2 { get; set; }
public decimal Mhz2 { get; set; } public decimal Mhz2 { get; set; }
public int Ram { get; set; } public int Ram { get; set; }
public int Vram { get; set; } public int Vram { get; set; }
public string Rigid { get; set; } public string Rigid { get; set; }
public int Disk1 { get; set; } public int Disk1 { get; set; }
public int Cap1 { get; set; } public int Cap1 { get; set; }
public int Disk2 { get; set; } public int Disk2 { get; set; }
public int Cap2 { get; set; } public int Cap2 { get; set; }
} }
} }

View File

@@ -2,12 +2,12 @@
{ {
public class OwnedConsoles public class OwnedConsoles
{ {
public int Id { get; set; } public int Id { get; set; }
public int DbId { get; set; } public int DbId { get; set; }
public string Date { get; set; } public string Date { get; set; }
public int Status { get; set; } public StatusType Status { get; set; }
public int Trade { get; set; } public int Trade { get; set; }
public int Boxed { get; set; } public int Boxed { get; set; }
public int Manuals { get; set; } public int Manuals { get; set; }
} }
} }

View File

@@ -2,11 +2,11 @@
{ {
public class StorageByMachine public class StorageByMachine
{ {
public int MachineId { get; set; } public int MachineId { get; set; }
public int Type { get; set; } public StorageType Type { get; set; }
public int Interface { get; set; } public StorageInterface Interface { get; set; }
public long? Capacity { get; set; } public long? Capacity { get; set; }
public long Id { get; set; } public long Id { get; set; }
public Machines Machine { get; set; } public Machines Machine { get; set; }
} }

View File

@@ -218,13 +218,13 @@ namespace Cicm.Database.Models
entity.Property(e => e.Text).HasColumnName("text").HasColumnType("text"); entity.Property(e => e.Text).HasColumnName("text").HasColumnType("text");
entity.HasOne(d => d.Company).WithOne(p => p.CompanyDescriptions) entity.HasOne(d => d.Company).WithOne(p => p.Description).HasForeignKey<CompanyDescriptions>(d => d.Id)
.HasForeignKey<CompanyDescriptions>(d => d.Id).HasConstraintName("fk_company_id"); .HasConstraintName("fk_company_id");
}); });
modelBuilder.Entity<CompanyLogos>(entity => modelBuilder.Entity<CompanyLogos>(entity =>
{ {
entity.HasKey(e => new {e.Id, e.CompanyId, e.LogoGuid}); entity.HasKey(e => new {e.Id, e.CompanyId, LogoGuid = e.Guid});
entity.ToTable("company_logos"); entity.ToTable("company_logos");
@@ -232,13 +232,13 @@ namespace Cicm.Database.Models
entity.HasIndex(e => e.Id).HasName("idx_id").IsUnique(); entity.HasIndex(e => e.Id).HasName("idx_id").IsUnique();
entity.HasIndex(e => e.LogoGuid).HasName("idx_guid"); entity.HasIndex(e => e.Guid).HasName("idx_guid");
entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)").ValueGeneratedOnAdd(); entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)").ValueGeneratedOnAdd();
entity.Property(e => e.CompanyId).HasColumnName("company_id").HasColumnType("int(11)"); entity.Property(e => e.CompanyId).HasColumnName("company_id").HasColumnType("int(11)");
entity.Property(e => e.LogoGuid).HasColumnName("logo_guid").HasColumnType("char(36)"); entity.Property(e => e.Guid).HasColumnName("logo_guid").HasColumnType("char(36)");
entity.Property(e => e.Year).HasColumnName("year").HasColumnType("int(4)"); entity.Property(e => e.Year).HasColumnName("year").HasColumnType("int(4)");