I am trying to add a Drink object via DbContext, but after adding the drink using the context, the Brand property becomes null. What could be the reason for this?
(Ignore the double _context add method, was debugging)
Before adding the drink
After adding the drink
Models:
public class Product
{
[Key]
public string Id { get; set; }
public string Name { get; set; }
}
public class Drink : Product
{
public Brand Brand { get; set; }
public Category Category { get; set; }
public ICollection<DrinkTag> DrinkTags { get; set; }
}
public class Brand
{
[Key]
public string Name { get; set; }
public ICollection<Drink> Drinks { get; set; }
}
public class Category
{
[Key]
public string Name { get; set; }
public ICollection<Drink> Drinks { get; set; }
}
public class Tag
{
[Key]
public string Name { get; set; }
public ICollection<Drink> Drinks { get; set; }
}
public class DrinkTag
{
public string DrinkId { get; set; }
public Drink Drink { get; set; }
public string TagId { get; set; }
public Tag Tag { get; set; }
}