mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add people by magazine.
This commit is contained in:
8124
Cicm.Database/Migrations/20190617030141_AddPeopleByMagazine.Designer.cs
generated
Normal file
8124
Cicm.Database/Migrations/20190617030141_AddPeopleByMagazine.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Cicm.Database.Migrations
|
||||
{
|
||||
public partial class AddPeopleByMagazine : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("PeopleByMagazines",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<long>()
|
||||
.Annotation("MySql:ValueGenerationStrategy",
|
||||
MySqlValueGenerationStrategy.IdentityColumn),
|
||||
PersonId = table.Column<int>(),
|
||||
MagazineId = table.Column<long>(),
|
||||
RoleId = table.Column<string>("char(3)")
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PeopleByMagazines", x => x.Id);
|
||||
table.ForeignKey("FK_PeopleByMagazines_MagazineIssues_MagazineId",
|
||||
x => x.MagazineId, "MagazineIssues", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_PeopleByMagazines_DocumentPeople_PersonId",
|
||||
x => x.PersonId, "DocumentPeople", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_PeopleByMagazines_DocumentRoles_RoleId",
|
||||
x => x.RoleId, "DocumentRoles", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex("IX_PeopleByMagazines_MagazineId", "PeopleByMagazines", "MagazineId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_PeopleByMagazines_PersonId", "PeopleByMagazines", "PersonId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_PeopleByMagazines_RoleId", "PeopleByMagazines", "RoleId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("PeopleByMagazines");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4901,6 +4901,27 @@ namespace Cicm.Database.Migrations
|
||||
b.ToTable("PeopleByDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.PeopleByMagazine", b =>
|
||||
{
|
||||
b.Property<long>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<long>("MagazineId");
|
||||
|
||||
b.Property<int>("PersonId");
|
||||
|
||||
b.Property<string>("RoleId").IsRequired().HasColumnType("char(3)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MagazineId");
|
||||
|
||||
b.HasIndex("PersonId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("PeopleByMagazines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.Person", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||
@@ -5780,6 +5801,18 @@ namespace Cicm.Database.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.PeopleByMagazine", b =>
|
||||
{
|
||||
b.HasOne("Cicm.Database.Models.MagazineIssue", "Magazine").WithMany("People")
|
||||
.HasForeignKey("MagazineId").OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("Cicm.Database.Models.DocumentPerson", "Person").WithMany("Magazines")
|
||||
.HasForeignKey("PersonId").OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("Cicm.Database.Models.DocumentRole", "Role").WithMany().HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.Person",
|
||||
b =>
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Cicm.Database.Models
|
||||
public virtual Person Person { get; set; }
|
||||
public virtual ICollection<PeopleByDocument> Documents { get; set; }
|
||||
public virtual ICollection<PeopleByBook> Books { get; set; }
|
||||
public virtual ICollection<PeopleByMagazine> Magazines { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string FullName => $"{Name} {Surname}";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
@@ -17,6 +18,7 @@ namespace Cicm.Database.Models
|
||||
public string ProductCode { get; set; }
|
||||
public short Pages { get; set; }
|
||||
|
||||
public virtual Magazine Magazine { get; set; }
|
||||
public virtual Magazine Magazine { get; set; }
|
||||
public virtual ICollection<PeopleByMagazine> People { get; set; }
|
||||
}
|
||||
}
|
||||
18
Cicm.Database/Models/PeopleByMagazine.cs
Normal file
18
Cicm.Database/Models/PeopleByMagazine.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class PeopleByMagazine : BaseModel<long>
|
||||
{
|
||||
public int PersonId { get; set; }
|
||||
public long MagazineId { get; set; }
|
||||
[Column(TypeName = "char(3)")]
|
||||
[Required]
|
||||
public string RoleId { get; set; }
|
||||
|
||||
public virtual DocumentPerson Person { get; set; }
|
||||
public virtual MagazineIssue Magazine { get; set; }
|
||||
public virtual DocumentRole Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,7 @@ namespace Cicm.Database.Models
|
||||
public virtual DbSet<Magazine> Magazines { get; set; }
|
||||
public virtual DbSet<MagazineIssue> MagazineIssues { get; set; }
|
||||
public virtual DbSet<CompaniesByMagazine> CompaniesByMagazines { get; set; }
|
||||
public virtual DbSet<PeopleByMagazine> PeopleByMagazines { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -1023,6 +1024,17 @@ namespace Cicm.Database.Models
|
||||
entity.HasOne(d => d.Document).WithMany(p => p.People).HasForeignKey(d => d.DocumentId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PeopleByMagazine>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.PersonId);
|
||||
|
||||
entity.HasIndex(e => e.MagazineId);
|
||||
|
||||
entity.HasOne(d => d.Person).WithMany(p => p.Magazines).HasForeignKey(d => d.PersonId);
|
||||
|
||||
entity.HasOne(d => d.Magazine).WithMany(p => p.People).HasForeignKey(d => d.MagazineId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Person>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.Name);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.833</Version>
|
||||
<Version>3.0.99.834</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