Raysefo

Raysefo

  • 1.5k
  • 284
  • 149.8k

EF Core 6 - InvalidIncludePathError' to the 'ConfigureWarnings' method

Aug 6 2022 3:23 PM

Hi,
I am getting this error;
'microsoft.entityframeworkcore.query.invalidincludepatherror': unable to find navigation 'vendors' specified in string based include path 'vendors'. this exception can be suppressed or logged by passing event id 'coreeventid.invalidincludepatherror' to the 'configurewarnings' method in 'dbcontext.onconfiguring' or 'adddbcontext'.

at this line of code;
return await this._db.Orders.Include("OrderDetails").Include("Vendors").ToListAsync();

Here are my related models;

public class Order
         {
             public int Id { get; set; }
                
             [Required]
             public DateTime OrderDateTime { get; set; }
             [Required]
             [MaxLength(250)]
             public string CustomerName { get; set; }
             public string Status { get; set; }
             [MaxLength(50)]
             public string DoneBy { get; set; }
             public List<OrderDetail> OrderDetails { get; set; }
        
         }
        
     public class OrderDetail
         {
             public int Id { get; set; }
                
             [Required]
             [MaxLength(100)]
             public string ProductCode { get; set; }
             [Required]
             [MaxLength(250)]
             public string ProductName { get; set; }
             [Required]
             public int BuyQuantity { get; set; }
             [Required]
             public int SellQuantity { get; set; }
             public double CostRatio { get; set; }
             public double UnitCost { get; set; }
             public double TotalBuyPrice { get; set; }
             public double TotalSellPrice { get; set; }
             [MaxLength(150)]
             public string ShippingNumber { get; set; }
             public string Status { get; set; }
             [MaxLength(150)]
             public string TrackingNumber { get; set; }
             [MaxLength(400)]
             public string Description { get; set; }
             public int OrderId { get; set; }
             [Required]
             [MaxLength(250)]
             public int VendorId { get; set; }
             public virtual Order Order { get; set; }
             public virtual Vendor Vendor { get; set; }
         }
     public class Vendor
         {
             public int Id { get; set; }
             [Required]
             public string Name { get; set; }
             [Required]
             public string Address { get; set; }
             [Required]
             [RegularExpression(@"^((?!\.)[\w-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$", ErrorMessage = "Invalid email address.")]
             public string Email { get; set; }
             [Required]
             public string PhoneNumber { get; set; }
             [Required]
             public string MainResponsibleName { get; set; }
             public string AssistantResponsibleName { get; set; }
         }

How can I fix?


Thanks in advance.


Answers (3)