using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace StockMaster.Models { [Table("sale_item", Schema = "stock_management")] public class SaleItem { [Column("sale_id")] public int SaleId { get; set; } [ForeignKey("SaleId")] public Sale Sale { get; set; } [Column("product_id")] public int ProductId { get; set; } [ForeignKey("ProductId")] public Product Product { get; set; } [Required(ErrorMessage = "Quantity is required")] [Range(1, int.MaxValue, ErrorMessage = "Quantity must be greater than 0")] [Column("quantity")] public int Quantity { get; set; } [Required(ErrorMessage = "Unit price is required")] [Range(0.01, double.MaxValue, ErrorMessage = "Unit price must be greater than 0")] [Column("unit_price_at_sale")] public decimal UnitPriceAtSale { get; set; } } }