Problems displaying data from an automatically generated table because of the relation n to n, Entity framework c#

Asked

Viewed 27 times

2

I am using Entity Framework code first in C#, I have the following classes.

Procedure (only the relevant part):

    public int Id { get; set; }
    public virtual ICollection<Produto> Produtos { get; set; }

Products (only the relevant section):

    public int Id { get; set; }
    public virtual ICollection<Procedimento> Procedimentos { get; set; }

My business rule generates an n for n, with a little research I could see that the best way to solve this would be to create the virtual attributes Icollection<> in both classes, my database was successfully generated but in both classes this field does not appear, in place was generated a tabelaprocedimentoproduto that contains the fields(IdProduto and IdProcedimento), I can safely save inside this new table, however, I cannot recover the data to work, my context does not identify this new table, I have tried to use include but was not successful.

  • 1

    Create a third class, it might even be that name ai, the process table, put the two inside it, and then map with hasmany(procedure). withmany(product)

  • could be a little clearer when mapping?

No answers

Browser other questions tagged

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