Add database entities for USB vendor and product IDs.

This commit is contained in:
2018-12-24 06:29:52 +00:00
parent 93baf690cd
commit 383794bace
14 changed files with 1809 additions and 0 deletions

View File

@@ -54,6 +54,8 @@ namespace DiscImageChef.Database
public DbSet<DeviceStat> SeenDevices { get; set; }
public DbSet<OperatingSystem> OperatingSystems { get; set; }
public DbSet<Version> Versions { get; set; }
public DbSet<UsbVendor> UsbVendors { get; set; }
public DbSet<UsbProduct> UsbProducts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{

View File

@@ -80,6 +80,8 @@
<Compile Include="Migrations\20181223183913_FixUnsignedFields.Designer.cs" />
<Compile Include="Migrations\20181223214411_UseBinaryDataForIdentifyInquiryAndModesInReports.cs" />
<Compile Include="Migrations\20181223214411_UseBinaryDataForIdentifyInquiryAndModesInReports.Designer.cs" />
<Compile Include="Migrations\20181224044809_StoreUsbIdsInDatabase.cs" />
<Compile Include="Migrations\20181224044809_StoreUsbIdsInDatabase.Designer.cs" />
<Compile Include="Migrations\DicContextModelSnapshot.cs" />
<Compile Include="Models\Command.cs" />
<Compile Include="Models\Device.cs" />
@@ -91,6 +93,8 @@
<Compile Include="Models\OperatingSystem.cs" />
<Compile Include="Models\Partition.cs" />
<Compile Include="Models\Report.cs" />
<Compile Include="Models\UsbProduct.cs" />
<Compile Include="Models\UsbVendor.cs" />
<Compile Include="Models\Version.cs" />
</ItemGroup>
<ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace DiscImageChef.Database.Migrations
{
public partial class StoreUsbIdsInDatabase : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("UsbVendors",
table => new
{
Id = table.Column<ushort>(nullable: false),
Vendor = table.Column<string>(nullable: true),
AddedWhen = table.Column<DateTime>(nullable: false),
ModifiedWhen = table.Column<DateTime>(nullable: false)
}, constraints: table => { table.PrimaryKey("PK_UsbVendors", x => x.Id); });
migrationBuilder.CreateTable("UsbProducts",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ProductId = table.Column<ushort>(nullable: false),
Product = table.Column<string>(nullable: true),
AddedWhen = table.Column<DateTime>(nullable: false),
ModifiedWhen = table.Column<DateTime>(nullable: false),
VendorId = table.Column<ushort>(nullable: false)
}, constraints: table =>
{
table.PrimaryKey("PK_UsbProducts", x => x.Id);
table.ForeignKey("FK_UsbProducts_UsbVendors_VendorId", x => x.VendorId,
"UsbVendors", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_UsbProducts_VendorId", "UsbProducts", "VendorId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("UsbProducts");
migrationBuilder.DropTable("UsbVendors");
}
}
}

View File

@@ -1122,6 +1122,42 @@ namespace DiscImageChef.Database.Migrations
b.ToTable("Reports");
});
modelBuilder.Entity("DiscImageChef.Database.Models.UsbProduct", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<DateTime>("AddedWhen");
b.Property<DateTime>("ModifiedWhen");
b.Property<string>("Product");
b.Property<ushort>("ProductId");
b.Property<ushort>("VendorId");
b.HasKey("Id");
b.HasIndex("VendorId");
b.ToTable("UsbProducts");
});
modelBuilder.Entity("DiscImageChef.Database.Models.UsbVendor", b =>
{
b.Property<ushort>("Id").ValueGeneratedOnAdd();
b.Property<DateTime>("AddedWhen");
b.Property<DateTime>("ModifiedWhen");
b.Property<string>("Vendor");
b.HasKey("Id");
b.ToTable("UsbVendors");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Version", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
@@ -1270,6 +1306,13 @@ namespace DiscImageChef.Database.Migrations
b.HasOne("DiscImageChef.CommonTypes.Metadata.Usb", "USB").WithMany().HasForeignKey("USBId");
});
modelBuilder.Entity("DiscImageChef.Database.Models.UsbProduct",
b =>
{
b.HasOne("DiscImageChef.Database.Models.UsbVendor", "Vendor").WithMany("Products")
.HasForeignKey("VendorId").OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class UsbProduct
{
public UsbProduct() { }
public UsbProduct(ushort vendorId, ushort id, string product)
{
ProductId = id;
Product = product;
AddedWhen = ModifiedWhen = DateTime.UtcNow;
}
[Key]
public int Id { get; set; }
public ushort ProductId { get; set; }
public string Product { get; set; }
public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; }
public ushort VendorId { get; set; }
public virtual UsbVendor Vendor { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class UsbVendor
{
public UsbVendor() { }
public UsbVendor(ushort id, string vendor)
{
Id = id;
Vendor = vendor;
AddedWhen = ModifiedWhen = DateTime.UtcNow;
}
[Key]
public ushort Id { get; set; }
public string Vendor { get; set; }
public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; }
public virtual ICollection<UsbProduct> Products { get; set; }
}
}

View File

@@ -217,6 +217,10 @@
<Compile Include="Migrations\201812232250198_UseBinaryDataForIdentifyInquiryAndModesInReports.Designer.cs">
<DependentUpon>201812232250198_UseBinaryDataForIdentifyInquiryAndModesInReports.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201812240552109_StoreUsbIdsInDatabase.cs" />
<Compile Include="Migrations\201812240552109_StoreUsbIdsInDatabase.Designer.cs">
<DependentUpon>201812240552109_StoreUsbIdsInDatabase.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\Command.cs" />
<Compile Include="Models\Context.cs" />
@@ -229,6 +233,8 @@
<Compile Include="Models\OperatingSystem.cs" />
<Compile Include="Models\Partition.cs" />
<Compile Include="Models\UploadedReport.cs" />
<Compile Include="Models\UsbProduct.cs" />
<Compile Include="Models\UsbVendor.cs" />
<Compile Include="Models\Version.cs" />
<Compile Include="Statistics.aspx.cs">
<DependentUpon>Statistics.aspx</DependentUpon>
@@ -316,6 +322,9 @@
<EmbeddedResource Include="Migrations\201812232250198_UseBinaryDataForIdentifyInquiryAndModesInReports.resx">
<DependentUpon>201812232250198_UseBinaryDataForIdentifyInquiryAndModesInReports.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201812240552109_StoreUsbIdsInDatabase.resx">
<DependentUpon>201812240552109_StoreUsbIdsInDatabase.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@@ -0,0 +1,29 @@
// <auto-generated />
namespace DiscImageChef.Server.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
public sealed partial class StoreUsbIdsInDatabase : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(StoreUsbIdsInDatabase));
string IMigrationMetadata.Id
{
get { return "201812240552109_StoreUsbIdsInDatabase"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}

View File

@@ -0,0 +1,39 @@
using System.Data.Entity.Migrations;
namespace DiscImageChef.Server.Migrations
{
public partial class StoreUsbIdsInDatabase : DbMigration
{
public override void Up()
{
CreateTable("dbo.UsbProducts",
c => new
{
Id = c.Int(false, true),
ProductId = c.Int(false),
Product = c.String(unicode: false),
AddedWhen = c.DateTime(false, 0),
ModifiedWhen = c.DateTime(false, 0),
VendorId = c.Int(false)
}).PrimaryKey(t => t.Id).ForeignKey("dbo.UsbVendors", t => t.VendorId, true)
.Index(t => t.VendorId);
CreateTable("dbo.UsbVendors",
c => new
{
Id = c.Int(false, true),
Vendor = c.String(unicode: false),
AddedWhen = c.DateTime(false, 0),
ModifiedWhen = c.DateTime(false, 0)
}).PrimaryKey(t => t.Id);
}
public override void Down()
{
DropForeignKey("dbo.UsbProducts", "VendorId", "dbo.UsbVendors");
DropIndex("dbo.UsbProducts", new[] {"VendorId"});
DropTable("dbo.UsbVendors");
DropTable("dbo.UsbProducts");
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -49,5 +49,7 @@ namespace DiscImageChef.Server.Models
public DbSet<OperatingSystem> OperatingSystems { get; set; }
public DbSet<Partition> Partitions { get; set; }
public DbSet<Version> Versions { get; set; }
public DbSet<UsbVendor> UsbVendors { get; set; }
public DbSet<UsbProduct> UsbProducts { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Server.Models
{
public class UsbProduct
{
public UsbProduct() { }
public UsbProduct(ushort vendorId, ushort id, string product)
{
ProductId = id;
Product = product;
AddedWhen = ModifiedWhen = DateTime.UtcNow;
}
[Key]
public int Id { get; set; }
public int ProductId { get; set; }
public string Product { get; set; }
public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; }
public int VendorId { get; set; }
public virtual UsbVendor Vendor { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Server.Models
{
public class UsbVendor
{
public UsbVendor() { }
public UsbVendor(ushort id, string vendor)
{
Id = id;
Vendor = vendor;
AddedWhen = ModifiedWhen = DateTime.UtcNow;
}
[Key]
public int Id { get; set; }
public string Vendor { get; set; }
public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; }
public virtual ICollection<UsbProduct> Products { get; set; }
}
}