fix ForeignKey constraints in DB models

This commit is contained in:
ShabOl 2024-04-30 23:03:49 +04:00
parent d427de2200
commit 48e52db40e
3 changed files with 10 additions and 2 deletions

View File

@ -21,9 +21,12 @@ namespace ComputerShopDatabaseImplement.Models
[Required]
public string Category { get; private set; } = string.Empty;
[ForeignKey("ComponentId")]
[ForeignKey("AssemblyId")]
public virtual List<AssemblyComponent> Components { get; set; } = new();
[ForeignKey("AssemblyId")]
public virtual List<Request> Requests { get; set; } = new();
private Dictionary<int, (IComponentModel, int)>? _assemblyComponents;
[NotMapped]

View File

@ -19,6 +19,9 @@ namespace ComputerShopDatabaseImplement.Models
[Required]
public double Cost { get; private set; }
[ForeignKey("ComponentId")]
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
[ForeignKey("ComponentId")]
public virtual List<AssemblyComponent> AssemblyComponents { get; set; } = new();

View File

@ -23,7 +23,9 @@ namespace ComputerShopDatabaseImplement.Models
public int? ShipmentId { get; set; }
[ForeignKey("ComponentId")]
public virtual Shipment? Shipment { get; set; }
[ForeignKey("ProductId")]
public virtual List<ProductComponent> Components { get; set; } = new();
private Dictionary<int, (IComponentModel, int)>? _productComponents;