Many to Many in EF Core Models

Posts   
 
    
rstrahl
User
Posts: 17
Joined: 24-Aug-2009
# Posted on: 17-Sep-2019 21:16:31   

I noticed that the model import from db does not support many to many imports for EF Core. While there's no single table mapping support, it's certainly possible to use link table mapping for M:M relationships.

Wouldn't that be an option for output generation and support of M:M.

I presume that can be done manually if necessary as long as the model editor can preserve those extra tables when resyncing from the db?

Otherwise what's the best approach you'd suggest with EF Core?

+++ Rick ---

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Sep-2019 09:03:57   

rstrahl wrote:

I noticed that the model import from db does not support many to many imports for EF Core.

Yes, many to many relationships is not supported.

rstrahl wrote:

While there's no single table mapping support, it's certainly possible to use link table mapping for M:M relationships.

What do you mean by "link table mapping for M:M relationships"?

rstrahl wrote:

I presume that can be done manually if necessary as long as the model editor can preserve those extra tables when resyncing from the db?

Otherwise what's the best approach you'd suggest with EF Core?

Actually, manually is the way MS recommend to treat m:n. See this: https://docs.microsoft.com/en-us/ef/core/modeling/relationships#many-to-many

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 18-Sep-2019 09:22:51   

yeah that 2 x m:1 is supported of course, it's just not creating another m:n between the two entities related to each other, in that example: post and tag. There's no way to specify in EF Core today that post and tag have a m:n relationship and you can utilize that to fetch them, e.g. fetch a post and all its tags using the m:n relationship like you can in our own runtime; this isn't supported by EF Core at the moment.

Frans Bouma | Lead developer LLBLGen Pro