Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I still need an explicit middle entity for N-to-N in EF under .NET Core 3?

I've read a few articles like this one where it's implied that the necessity of an explicit entity AB between A and B.

When I google this, I can't find any official info confirming nor contradicting that statement. On the other hand, documentation for preview versions might be less than fully covering.

Is it possible in .NET Core 3 or are we still forced to manually create the N-to-N entities?

like image 637
Konrad Viltersten Avatar asked Jul 19 '19 18:07

Konrad Viltersten


People also ask

How does Entity Framework handle many-to-many relationships in core?

Many-to-many relationships require a collection navigation property on both sides. They will be discovered by convention like other types of relationships. The way this relationship is implemented in the database is by a join table that contains foreign keys to both Post and Tag .

Should I use EF core or EF6?

Keep using EF6 if the data access code is stable and not likely to evolve or need new features. Port to EF Core if the data access code is evolving or if the app needs new features only available in EF Core.

Can you use Entity Framework with net framework?

You can use EF Core in APIs and applications that require the full . NET Framework, as well as those that target only the cross-platform .


1 Answers

The feature you (and not only) are asking for is tracked by #10508: Implement many-to-many relationships without mapping join table.

As you can see, the status is Backlog, which means it is considered, but no concrete schedule. Also the last comment by the EF Core team (manager) is

Current plan for 3.0 is to implement skip-level navigation properties as a stretch goal. If property bags (#9914) also make it into 3.0, enabling a seamless experience for many-to-many could become easier.

Also it's not listed in the New features. And just referenced in Property bag entities

This feature is a stepping stone to support many-to-many relationships without a join entity (issue #1368), which is one of the most requested improvements for EF Core.

where #1368 refers to Discussion on many-to-Many relationships (without CLR class for join table).


All that simply means that the answer to your question is - no, this feature won't be in 3.0, hence you should continue using explicit join entity.

like image 104
Ivan Stoev Avatar answered Oct 07 '22 01:10

Ivan Stoev