mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add companies by book.
This commit is contained in:
7843
Cicm.Database/Migrations/20190617014131_AddCompaniesByBook.Designer.cs
generated
Normal file
7843
Cicm.Database/Migrations/20190617014131_AddCompaniesByBook.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Cicm.Database.Migrations
|
||||
{
|
||||
public partial class AddCompaniesByBook : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("CompaniesByBooks",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<long>()
|
||||
.Annotation("MySql:ValueGenerationStrategy",
|
||||
MySqlValueGenerationStrategy.IdentityColumn),
|
||||
CompanyId = table.Column<int>(),
|
||||
BookId = table.Column<long>(),
|
||||
RoleId = table.Column<string>("char(3)")
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CompaniesByBooks", x => x.Id);
|
||||
table.ForeignKey("FK_CompaniesByBooks_Books_BookId", x => x.BookId,
|
||||
"Books", "Id", onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_CompaniesByBooks_DocumentCompanies_CompanyId",
|
||||
x => x.CompanyId, "DocumentCompanies", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_CompaniesByBooks_DocumentRoles_RoleId", x => x.RoleId,
|
||||
"DocumentRoles", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex("IX_CompaniesByBooks_BookId", "CompaniesByBooks", "BookId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_CompaniesByBooks_CompanyId", "CompaniesByBooks", "CompanyId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_CompaniesByBooks_RoleId", "CompaniesByBooks", "RoleId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("CompaniesByBooks");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,5 +17,6 @@ namespace Cicm.Database.Models
|
||||
public virtual Book Next { get; set; }
|
||||
public virtual Iso31661Numeric Country { get; set; }
|
||||
public virtual ICollection<Book> Derivates { get; set; }
|
||||
public virtual ICollection<CompaniesByBook> Companies { get; set; }
|
||||
}
|
||||
}
|
||||
18
Cicm.Database/Models/CompaniesByBook.cs
Normal file
18
Cicm.Database/Models/CompaniesByBook.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class CompaniesByBook : BaseModel<long>
|
||||
{
|
||||
public int CompanyId { get; set; }
|
||||
public long BookId { get; set; }
|
||||
[Column(TypeName = "char(3)")]
|
||||
[Required]
|
||||
public string RoleId { get; set; }
|
||||
|
||||
public virtual DocumentCompany Company { get; set; }
|
||||
public virtual Book Book { get; set; }
|
||||
public virtual DocumentRole Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,6 @@ namespace Cicm.Database.Models
|
||||
|
||||
public virtual Company Company { get; set; }
|
||||
public virtual ICollection<CompaniesByDocument> Documents { get; set; }
|
||||
public virtual ICollection<CompaniesByBook> Books { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@ namespace Cicm.Database.Models
|
||||
public virtual DbSet<CompaniesByDocument> CompaniesByDocuments { get; set; }
|
||||
public virtual DbSet<DocumentsByMachine> DocumentsByMachines { get; set; }
|
||||
public virtual DbSet<Book> Books { get; set; }
|
||||
public virtual DbSet<CompaniesByBook> CompaniesByBooks { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -202,6 +203,19 @@ namespace Cicm.Database.Models
|
||||
entity.Property(e => e.Version).HasColumnName("version").HasColumnType("int(11)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CompaniesByBook>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.BookId);
|
||||
|
||||
entity.HasIndex(e => e.CompanyId);
|
||||
|
||||
entity.HasIndex(e => e.RoleId);
|
||||
|
||||
entity.HasOne(d => d.Book).WithMany(p => p.Companies).HasForeignKey(d => d.BookId);
|
||||
|
||||
entity.HasOne(d => d.Company).WithMany(p => p.Books).HasForeignKey(d => d.CompanyId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CompaniesByDocument>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.DocumentId);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.825</Version>
|
||||
<Version>3.0.99.826</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