mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add companies by magazine.
This commit is contained in:
8082
Cicm.Database/Migrations/20190617025439_AddCompaniesByMagazine.Designer.cs
generated
Normal file
8082
Cicm.Database/Migrations/20190617025439_AddCompaniesByMagazine.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 AddCompaniesByMagazine : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("CompaniesByMagazines",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<long>()
|
||||
.Annotation("MySql:ValueGenerationStrategy",
|
||||
MySqlValueGenerationStrategy.IdentityColumn),
|
||||
CompanyId = table.Column<int>(),
|
||||
MagazineId = table.Column<long>(),
|
||||
RoleId = table.Column<string>("char(3)")
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CompaniesByMagazines", x => x.Id);
|
||||
table.ForeignKey("FK_CompaniesByMagazines_DocumentCompanies_CompanyId",
|
||||
x => x.CompanyId, "DocumentCompanies", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_CompaniesByMagazines_Magazines_MagazineId",
|
||||
x => x.MagazineId, "Magazines", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_CompaniesByMagazines_DocumentRoles_RoleId",
|
||||
x => x.RoleId, "DocumentRoles", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex("IX_CompaniesByMagazines_CompanyId", "CompaniesByMagazines", "CompanyId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_CompaniesByMagazines_MagazineId", "CompaniesByMagazines", "MagazineId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_CompaniesByMagazines_RoleId", "CompaniesByMagazines", "RoleId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("CompaniesByMagazines");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,6 +222,27 @@ namespace Cicm.Database.Migrations
|
||||
b.ToTable("CompaniesByDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.CompaniesByMagazine", b =>
|
||||
{
|
||||
b.Property<long>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("CompanyId");
|
||||
|
||||
b.Property<long>("MagazineId");
|
||||
|
||||
b.Property<string>("RoleId").IsRequired().HasColumnType("char(3)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.HasIndex("MagazineId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("CompaniesByMagazines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.Company", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)");
|
||||
@@ -5541,6 +5562,18 @@ namespace Cicm.Database.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.CompaniesByMagazine", b =>
|
||||
{
|
||||
b.HasOne("Cicm.Database.Models.DocumentCompany", "Company").WithMany("Magazines")
|
||||
.HasForeignKey("CompanyId").OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("Cicm.Database.Models.Magazine", "Magazine").WithMany("Companies").HasForeignKey("MagazineId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("Cicm.Database.Models.DocumentRole", "Role").WithMany().HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.Company", b =>
|
||||
{
|
||||
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "Country").WithMany("Companies")
|
||||
|
||||
18
Cicm.Database/Models/CompaniesByMagazine.cs
Normal file
18
Cicm.Database/Models/CompaniesByMagazine.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class CompaniesByMagazine : BaseModel<long>
|
||||
{
|
||||
public int CompanyId { get; set; }
|
||||
public long MagazineId { get; set; }
|
||||
[Column(TypeName = "char(3)")]
|
||||
[Required]
|
||||
public string RoleId { get; set; }
|
||||
|
||||
public virtual DocumentCompany Company { get; set; }
|
||||
public virtual Magazine Magazine { get; set; }
|
||||
public virtual DocumentRole Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace Cicm.Database.Models
|
||||
|
||||
public virtual Company Company { get; set; }
|
||||
public virtual ICollection<CompaniesByDocument> Documents { get; set; }
|
||||
public virtual ICollection<CompaniesByBook> Books { get; set; }
|
||||
public virtual ICollection<CompaniesByBook> Books { get; set; }
|
||||
public virtual ICollection<CompaniesByMagazine> Magazines { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ namespace Cicm.Database.Models
|
||||
[DataType(DataType.Date)]
|
||||
public DateTime? FirstPublication { get; set; }
|
||||
|
||||
public virtual Iso31661Numeric Country { get; set; }
|
||||
public virtual ICollection<MagazineIssue> Issues { get; set; }
|
||||
public virtual Iso31661Numeric Country { get; set; }
|
||||
public virtual ICollection<MagazineIssue> Issues { get; set; }
|
||||
public virtual ICollection<CompaniesByMagazine> Companies { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ namespace Cicm.Database.Models
|
||||
public virtual DbSet<BooksByMachineFamily> BooksByMachineFamilies { get; set; }
|
||||
public virtual DbSet<Magazine> Magazines { get; set; }
|
||||
public virtual DbSet<MagazineIssue> MagazineIssues { get; set; }
|
||||
public virtual DbSet<CompaniesByMagazine> CompaniesByMagazines { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -256,6 +257,19 @@ namespace Cicm.Database.Models
|
||||
entity.HasOne(d => d.Company).WithMany(p => p.Documents).HasForeignKey(d => d.CompanyId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CompaniesByMagazine>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.MagazineId);
|
||||
|
||||
entity.HasIndex(e => e.CompanyId);
|
||||
|
||||
entity.HasIndex(e => e.RoleId);
|
||||
|
||||
entity.HasOne(d => d.Magazine).WithMany(p => p.Companies).HasForeignKey(d => d.MagazineId);
|
||||
|
||||
entity.HasOne(d => d.Company).WithMany(p => p.Magazines).HasForeignKey(d => d.CompanyId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Company>(entity =>
|
||||
{
|
||||
entity.ToTable("companies");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.831</Version>
|
||||
<Version>3.0.99.833</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