2
I am developing these classes of this diagram, but I am in doubt how to declare relationships [One for many, and many for one]
for example Product has a Category, and a Category has Multiple Products:
public class Produto
{
[Key]
public int Codigo { 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 class person who has address I made:
public class Pessoa
{
[Key]
public int Codigo { get; set; }
...
public int EnderecoId { get; set; }
public Endereco Endereco { get; set; }
}
Is that statement correct?
Grateful
I’m trying to learn from this: https://msdn.microsoft.com/en-us/library/jj591620(v=vs.113). aspx if I can understand everything, put here dps
– Rovann Linhalis