I'm developing these classes in this diagram, but I'm not sure how to declare relationships [One for many, many for one]
forexampleProducthasaCategory,andCategoryhasseveralProducts:
publicclassProduto{[Key]publicintCodigo{get;set;}[Display(Name="Descrição")]
public string Descricao { get; set; }
[Display (Name = "Preço de Compra")]
public double PrecoCompra { get; set; }
[Display (Name = "Preço de Venda")]
public double PrecoVenda { get; set; }
public double Desconto { get; set; }
public string Imagem { get; set; }
public string Garantia { get; set; }
public string Fabricante { get; set; }
}
Category
public class Categoria
{
public int Codigo { get; set; }
public string Nome { get; set; }
public double Desconto { get; set; }
}
How do I declare them for EF to understand these relationships?
In this diagram, to declare the person class that has address I did:
public class Pessoa
{
[Key]
public int Codigo { get; set; }
...
public int EnderecoId { get; set; }
public Endereco Endereco { get; set; }
}
Is this statement correct?
Thankful