3
I need to do an Inner Join on Entity frameworkm in the bank, I can do normally this way:
select * from Produtos inner join ProdutosEmpresas on ProdutoID = Produtos.Id
But in the Entity framework I can not, it does not show the table to do include.
Here’s how it is currently:
var produtos = db.Produtos.OrderBy(a => a.Codigo).Where(a => a.ControleEstoque == true).ToList();
I need to make the Products table Inner Join with the table Productssempresas. I tried to make with Include, but it does not show the table to put. I do not understand why.
ProdutosEmpresas
 public class ProdutosEmpresas
{
    [Key]
    public int Id { get; set; }
    public Empresa EmpresaProduto { get; set; }
    public int EmpresaID { get; set; }
    public Produto ProdutoEmpresa { get; set; }
    public int ProdutoID { get; set; }
    public int Qtd { get; set; }
    public decimal PrecoCusto { get; set; }
    [DataType(DataType.Currency)]
    public decimal PrecoVenda { get; set; }
}
Produtos
 public class Produto
{
    [Key]
    public int Id { get; set; }
    [StringLength(100)]
    public string Codigo { get; set; }
    [StringLength(120)]
    public string nome { get; set; }
    public int QtdAtual { get; set; }
    public int QtdMinima { get; set; }
    public int QtdMaxima { get; set; }
    public decimal PrecoCusto { get; set; }
    [DataType(DataType.Currency)]
    public decimal PrecoVenda { get; set; }
    public decimal CustoMedio { get; set; }
    public float ICMS { get; set; }
    public float ISS { get; set; }
    public float IPI { get; set; }
    public float Margem { get; set; }
    public float Comissao { get; set; }
    public int CategoriaID { get; set; }
    public Categoria Categoria { get; set; }
    //public int EmpresaID { get; set; }
    //public Empresa Empresa { get; set; }
    [StringLength(500)]
    public string observacao { get; set; }
    [StringLength(8)]
    public string NCM { get; set; }
    public bool ControleEstoque { get; set; }
    public byte[] Foto { get; set; }
    public bool TipoProduto { get; set; }
    public bool TipoSoftware { get; set; }
}
Can you post the code of your Products and Products organizations? If you’ve done the relationship between them maybe you don’t even need the include.
– George Wurthmann
@Georgewurthmann updated the question with Products and Products.
– Mariana
Missing the reference property in Product Marketing. http://www.entityframeworktutorial.net/entity-relationships.aspx
– Netinho Santos
https://docs.microsoft.com/pt-br/ef/ef6/fundamentals/relationships
– Netinho Santos