modelBuilder.Entity<Transaction>().Property("ItemsSoldAndAmount").IsRequired();
public class Transaction{... [Required] public List<AmountItem> ItemsSoldAndAmount { get; set; } = new List<AmountItem>();...}
public class AmountItem{ [Required] public ObjectId Identifier { get; set; } [Required] public Item? Item { get; set; } [Required] public double amount { get; set; }}
[Collection("warehouse.transactions")]public class Transaction{ public ObjectId id { get; set; } = ObjectId.GenerateNewId(); [Required] public DateTime Time { get; set; } = DateTime.UtcNow; [Required] public double Amount { get; set; } [Required] public Item? Item { get; set; } [Required] public Warehouse? Warehouse { get; set; } [Required] public Buyer? Buyer { get; set; } [Required] public Staff? Staff { get; set; }}