diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs index 428f670..966a181 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs @@ -18,7 +18,7 @@ namespace ElectronicsShopDataBaseImplement.Models public int ID { get; set; } [Required] public double Sum { get; set; } - [Required] + [ForeignKey("UserID")] public int UserID { get; set; } [Required] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/OrderProducts.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/OrderProducts.cs index 11a056e..2365706 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/OrderProducts.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/OrderProducts.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,10 +12,10 @@ namespace ElectronicsShopDataBaseImplement.Models { public int ID { get; set; } - [Required] + [ForeignKey("OrderID")] public int OrdersID { get; set; } - [Required] + [ForeignKey("ProductID")] public int ProductID { get; set; } [Required] diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Product.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Product.cs index 9bcbbfe..414403a 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Product.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Product.cs @@ -4,6 +4,7 @@ using ElectronicsShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -17,7 +18,7 @@ namespace ElectronicsShopDataBaseImplement.Models public string ProductName { get; set; }=string.Empty; [Required] public double Price { get; set; } - [Required] + [ForeignKey("CategoryID")] public int CategoryID { get; set; } public static Product? Create(ProductBindingModel? model) diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/User.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/User.cs index 3dcdec3..12405c9 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/User.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/User.cs @@ -4,6 +4,7 @@ using ElectronicsShopDataModels; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -25,7 +26,7 @@ namespace ElectronicsShopDataBaseImplement.Models public string Login { get; set; } = string.Empty; [Required] public string Email { get; set; } = string.Empty; - [Required] + [ForeignKey("RoleID")] public int RoleID { get; set; } public static User? Create(UserBindingModel model)