Witam.
Walcze od rana z relacjami w moim projekcie. Podczas dodawania nowego produktu otrzymuję błąd:
Entities in 'ApplicationDbContext.Products' participate in the 'Suplier_Products' relationship. 0 related 'Suplier_Products_Source' were found. 1 'Suplier_Products_Source' is expected.
Moje dwa modele:
Product:
public class Product
{
public Product()
{
Category = new List<ProductCategory>();
}
public int Id { get; set; }
public string ProductName { get; set; } // nazwa produktu
public string ProductDescription { get; set; } // opis produktu
public string ProductImageUrl { get; set; } // url do obrazka produktu
public ICollection<ProductCategory> Category { get; set; } // kategorie produktu
public decimal PricePerUnit { get; set; } // cena jednostkowa
public int PremiumPoints { get; set; } // punkty zniżki za każdy zakupiony produkt
public int ProductQuantity { get; set; } // ilość na stanie
public virtual NutritionalValue NutritionalValues { get; set; } // wartości odżywcze
public virtual Suplier Suplier { get; set; } // dostawcy produktu
}
I dostawca Suplier
public class Suplier
{
public int Id { get; set; }
public string CompanyName { get; set; } // nazwa firmy
public ICollection<Addresses> Address { get; set; } // jej adresy
public ICollection<Product> Products { get; set; }
}
Co robię źle? :)