Use license table in machine photos.

This commit is contained in:
2019-05-27 18:03:08 +01:00
parent 82956c6b77
commit 574176ee4c
7 changed files with 5452 additions and 8 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class UseLicenseInMachinePhoto : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex("IX_MachinePhotos_License", "MachinePhotos");
migrationBuilder.DropColumn("License", "MachinePhotos");
migrationBuilder.AddColumn<int>("LicenseId", "MachinePhotos", nullable: false, defaultValue: 0);
migrationBuilder.CreateIndex("IX_MachinePhotos_LicenseId", "MachinePhotos", "LicenseId");
migrationBuilder.AddForeignKey("FK_MachinePhotos_Licenses_LicenseId", "MachinePhotos", "LicenseId",
"Licenses", principalColumn: "Id", onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey("FK_MachinePhotos_Licenses_LicenseId", "MachinePhotos");
migrationBuilder.DropIndex("IX_MachinePhotos_LicenseId", "MachinePhotos");
migrationBuilder.DropColumn("LicenseId", "MachinePhotos");
migrationBuilder.AddColumn<string>("License", "MachinePhotos", nullable: true);
migrationBuilder.CreateIndex("IX_MachinePhotos_License", "MachinePhotos", "License");
}
}
}

View File

@@ -3750,7 +3750,7 @@ namespace Cicm.Database.Migrations
b.Property<string>("Lens");
b.Property<string>("License");
b.Property<int>("LicenseId");
b.Property<string>("LightSource");
@@ -3824,7 +3824,7 @@ namespace Cicm.Database.Migrations
b.HasIndex("Lens");
b.HasIndex("License");
b.HasIndex("LicenseId");
b.HasIndex("LightSource");
@@ -4566,6 +4566,9 @@ namespace Cicm.Database.Migrations
modelBuilder.Entity("Cicm.Database.Models.MachinePhoto", b =>
{
b.HasOne("Cicm.Database.Models.License", "License").WithMany("Photos").HasForeignKey("LicenseId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Cicm.Database.Models.Machine", "Machine").WithMany("Photos").HasForeignKey("MachineId")
.OnDelete(DeleteBehavior.Cascade);

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -23,5 +24,6 @@ namespace Cicm.Database.Models
[Column(TypeName = "longtext")]
[StringLength(131072)]
public string Text { get; set; }
public virtual ICollection<MachinePhoto> Photos { get; set; }
}
}

View File

@@ -41,7 +41,6 @@ namespace Cicm.Database.Models
public int? IsoRating { get; set; }
[DisplayName("Lens used")]
public string Lens { get; set; }
public string License { get; set; }
[DisplayName("Light source")]
public string LightSource { get; set; }
[DisplayName("Metering mode")]
@@ -70,5 +69,7 @@ namespace Cicm.Database.Models
public virtual ApplicationUser User { get; set; }
public virtual Machine Machine { get; set; }
[Required]
public virtual License License { get; set; }
}
}

View File

@@ -521,8 +521,6 @@ namespace Cicm.Database.Models
entity.HasIndex(e => e.Lens);
entity.HasIndex(e => e.License);
entity.HasIndex(e => e.LightSource);
entity.HasIndex(e => e.MeteringMode);
@@ -554,6 +552,8 @@ namespace Cicm.Database.Models
entity.HasOne(d => d.Machine).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade);
entity.HasOne(d => d.User).WithMany(p => p.Photos).OnDelete(DeleteBehavior.SetNull);
entity.HasOne(d => d.License).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<MemoryByMachine>(entity =>

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.591</Version>
<Version>3.0.99.597</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>