mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add people by book.
This commit is contained in:
7885
Cicm.Database/Migrations/20190617015011_AddPeopleByBook.Designer.cs
generated
Normal file
7885
Cicm.Database/Migrations/20190617015011_AddPeopleByBook.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
44
Cicm.Database/Migrations/20190617015011_AddPeopleByBook.cs
Normal file
44
Cicm.Database/Migrations/20190617015011_AddPeopleByBook.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddPeopleByBook : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable("PeopleByBooks",
|
||||||
|
table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>()
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy",
|
||||||
|
MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
PersonId = table.Column<int>(),
|
||||||
|
BookId = table.Column<long>(),
|
||||||
|
RoleId = table.Column<string>("char(3)")
|
||||||
|
}, constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PeopleByBooks", x => x.Id);
|
||||||
|
table.ForeignKey("FK_PeopleByBooks_Books_BookId", x => x.BookId, "Books",
|
||||||
|
"Id", onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey("FK_PeopleByBooks_DocumentPeople_PersonId",
|
||||||
|
x => x.PersonId, "DocumentPeople", "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey("FK_PeopleByBooks_DocumentRoles_RoleId", x => x.RoleId,
|
||||||
|
"DocumentRoles", "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_PeopleByBooks_BookId", "PeopleByBooks", "BookId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_PeopleByBooks_PersonId", "PeopleByBooks", "PersonId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_PeopleByBooks_RoleId", "PeopleByBooks", "RoleId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable("PeopleByBooks");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -12,11 +12,12 @@ namespace Cicm.Database.Models
|
|||||||
public long? PreviousId { get; set; }
|
public long? PreviousId { get; set; }
|
||||||
public long? SourceId { get; set; }
|
public long? SourceId { get; set; }
|
||||||
|
|
||||||
public virtual Book Previous { get; set; }
|
public virtual Book Previous { get; set; }
|
||||||
public virtual Book Source { get; set; }
|
public virtual Book Source { get; set; }
|
||||||
public virtual Book Next { get; set; }
|
public virtual Book Next { get; set; }
|
||||||
public virtual Iso31661Numeric Country { get; set; }
|
public virtual Iso31661Numeric Country { get; set; }
|
||||||
public virtual ICollection<Book> Derivates { get; set; }
|
public virtual ICollection<Book> Derivates { get; set; }
|
||||||
public virtual ICollection<CompaniesByBook> Companies { get; set; }
|
public virtual ICollection<CompaniesByBook> Companies { get; set; }
|
||||||
|
public virtual ICollection<PeopleByBook> People { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ namespace Cicm.Database.Models
|
|||||||
|
|
||||||
public virtual Person Person { get; set; }
|
public virtual Person Person { get; set; }
|
||||||
public virtual ICollection<PeopleByDocument> Documents { get; set; }
|
public virtual ICollection<PeopleByDocument> Documents { get; set; }
|
||||||
|
public virtual ICollection<PeopleByBook> Books { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string FullName => $"{Name} {Surname}";
|
public string FullName => $"{Name} {Surname}";
|
||||||
|
|||||||
18
Cicm.Database/Models/PeopleByBook.cs
Normal file
18
Cicm.Database/Models/PeopleByBook.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Models
|
||||||
|
{
|
||||||
|
public class PeopleByBook : BaseModel<long>
|
||||||
|
{
|
||||||
|
public int PersonId { get; set; }
|
||||||
|
public long BookId { get; set; }
|
||||||
|
[Column(TypeName = "char(3)")]
|
||||||
|
[Required]
|
||||||
|
public string RoleId { get; set; }
|
||||||
|
|
||||||
|
public virtual DocumentPerson Person { get; set; }
|
||||||
|
public virtual Book Book { get; set; }
|
||||||
|
public virtual DocumentRole Role { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,7 +86,8 @@ namespace Cicm.Database.Models
|
|||||||
public virtual DbSet<CompaniesByDocument> CompaniesByDocuments { get; set; }
|
public virtual DbSet<CompaniesByDocument> CompaniesByDocuments { get; set; }
|
||||||
public virtual DbSet<DocumentsByMachine> DocumentsByMachines { get; set; }
|
public virtual DbSet<DocumentsByMachine> DocumentsByMachines { get; set; }
|
||||||
public virtual DbSet<Book> Books { get; set; }
|
public virtual DbSet<Book> Books { get; set; }
|
||||||
public virtual DbSet<CompaniesByBook> CompaniesByBooks { get; set; }
|
public virtual DbSet<CompaniesByBook> CompaniesByBooks { get; set; }
|
||||||
|
public virtual DbSet<PeopleByBook> PeopleByBooks { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@@ -215,7 +216,7 @@ namespace Cicm.Database.Models
|
|||||||
|
|
||||||
entity.HasOne(d => d.Company).WithMany(p => p.Books).HasForeignKey(d => d.CompanyId);
|
entity.HasOne(d => d.Company).WithMany(p => p.Books).HasForeignKey(d => d.CompanyId);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<CompaniesByDocument>(entity =>
|
modelBuilder.Entity<CompaniesByDocument>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasIndex(e => e.DocumentId);
|
entity.HasIndex(e => e.DocumentId);
|
||||||
@@ -909,6 +910,17 @@ namespace Cicm.Database.Models
|
|||||||
entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'");
|
entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<PeopleByBook>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasIndex(e => e.PersonId);
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.BookId);
|
||||||
|
|
||||||
|
entity.HasOne(d => d.Person).WithMany(p => p.Books).HasForeignKey(d => d.PersonId);
|
||||||
|
|
||||||
|
entity.HasOne(d => d.Book).WithMany(p => p.People).HasForeignKey(d => d.BookId);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<PeopleByCompany>(entity =>
|
modelBuilder.Entity<PeopleByCompany>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasIndex(e => e.PersonId);
|
entity.HasIndex(e => e.PersonId);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.826</Version>
|
<Version>3.0.99.827</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user