Add books by machine.

This commit is contained in:
2019-06-17 03:13:49 +01:00
parent df5d28d6a4
commit 565241f1c3
8 changed files with 8005 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddBooksByMachine : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("BooksByMachines",
table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
BookId = table.Column<long>(),
MachineId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_BooksByMachines", x => x.Id);
table.ForeignKey("FK_BooksByMachines_Books_BookId", x => x.BookId, "Books",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_BooksByMachines_machines_MachineId", x => x.MachineId,
"machines", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_BooksByMachines_BookId", "BooksByMachines", "BookId");
migrationBuilder.CreateIndex("IX_BooksByMachines_MachineId", "BooksByMachines", "MachineId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("BooksByMachines");
}
}
}

View File

@@ -65,6 +65,23 @@ namespace Cicm.Database.Migrations
b.ToTable("Books");
});
modelBuilder.Entity("Cicm.Database.Models.BooksByMachine", b =>
{
b.Property<long>("Id").ValueGeneratedOnAdd();
b.Property<long>("BookId");
b.Property<int>("MachineId");
b.HasKey("Id");
b.HasIndex("BookId");
b.HasIndex("MachineId");
b.ToTable("BooksByMachines");
});
modelBuilder.Entity("Cicm.Database.Models.BrowserTest", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)");
@@ -5395,6 +5412,15 @@ namespace Cicm.Database.Migrations
b.HasOne("Cicm.Database.Models.Book", "Source").WithMany("Derivates").HasForeignKey("SourceId");
});
modelBuilder.Entity("Cicm.Database.Models.BooksByMachine", b =>
{
b.HasOne("Cicm.Database.Models.Book", "Book").WithMany("Machines").HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Cicm.Database.Models.Machine", "Machine").WithMany("Books").HasForeignKey("MachineId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Cicm.Database.Models.CompaniesByBook", b =>
{
b.HasOne("Cicm.Database.Models.Book", "Book").WithMany("Companies").HasForeignKey("BookId")

View File

@@ -19,5 +19,6 @@ namespace Cicm.Database.Models
public virtual ICollection<Book> Derivates { get; set; }
public virtual ICollection<CompaniesByBook> Companies { get; set; }
public virtual ICollection<PeopleByBook> People { get; set; }
public virtual ICollection<BooksByMachine> Machines { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace Cicm.Database.Models
{
public class BooksByMachine : BaseModel<long>
{
public long BookId { get; set; }
public int MachineId { get; set; }
public virtual Book Book { get; set; }
public virtual Machine Machine { get; set; }
}
}

View File

@@ -71,6 +71,7 @@ namespace Cicm.Database.Models
public virtual ICollection<MachinePhoto> Photos { get; set; }
public virtual ICollection<ScreensByMachine> Screens { get; set; }
public virtual ICollection<DocumentsByMachine> Documents { get; set; }
public virtual ICollection<BooksByMachine> Books { get; set; }
[NotMapped]
[DisplayName("Introduced")]

View File

@@ -88,6 +88,7 @@ namespace Cicm.Database.Models
public virtual DbSet<Book> Books { get; set; }
public virtual DbSet<CompaniesByBook> CompaniesByBooks { get; set; }
public virtual DbSet<PeopleByBook> PeopleByBooks { get; set; }
public virtual DbSet<BooksByMachine> BooksByMachines { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -129,6 +130,17 @@ namespace Cicm.Database.Models
entity.HasOne(d => d.Country).WithMany(p => p.Books).HasForeignKey(d => d.CountryId);
});
modelBuilder.Entity<BooksByMachine>(entity =>
{
entity.HasIndex(e => e.BookId);
entity.HasIndex(e => e.MachineId);
entity.HasOne(d => d.Book).WithMany(p => p.Machines).HasForeignKey(d => d.BookId);
entity.HasOne(d => d.Machine).WithMany(p => p.Books).HasForeignKey(d => d.MachineId);
});
modelBuilder.Entity<BrowserTest>(entity =>
{
entity.ToTable("browser_tests");

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.827</Version>
<Version>3.0.99.828</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>