Composite key navigation

Asked

Viewed 32 times

0

Hello, I have a class with 2 keys composed

 public class Produto_Empresa
 {
        [Key,Column(Order = 0)]
        public int id_produto { get; set; }

        [Key, Column(Order = 1)]
        public int id_empresa { get; set; }
 }

I wonder if it’s right I put it on the Product_company:

public virtual Produto produto { get; set; }


public class Produto
{
       public int id { get; set; }
}

Or put public virtual ICollection<Produto_Empresa> ProdutoEmpresa { get; set; } in the Product class.

  • Lack a context, you made a relationship many to many by the Product Company class, but,,,,,,,,,,, the question lacks more data and one remark: you have a composite key with 2 correct fields ?!

  • Yes, the Product_company has 2 primary keys, which is the product table and the company table

  • You’re exactly doing what?

  • I want to know what the relationship looks like, within the classes, using 2 primary composite keys

  • If you use any Orms?

  • to using the Entity Framework

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.