mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add books by machine.
This commit is contained in:
7916
Cicm.Database/Migrations/20190617020655_AddBooksByMachine.Designer.cs
generated
Normal file
7916
Cicm.Database/Migrations/20190617020655_AddBooksByMachine.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
37
Cicm.Database/Migrations/20190617020655_AddBooksByMachine.cs
Normal file
37
Cicm.Database/Migrations/20190617020655_AddBooksByMachine.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
11
Cicm.Database/Models/BooksByMachine.cs
Normal file
11
Cicm.Database/Models/BooksByMachine.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user