many-to-many relationships without a joining entity
I know this probably gets asked a lot, but is adding support for many-to-many relationships without a joining entity on the roadmap? If so where?
Jason
How do u imagine many to many withour midle entity ?
By concept many many must use 3 entity !
It does currently in EF 6.x and previous versions of EF as well as in Resharper. I know linking tables are necessary in relational databases for many-to-many relationships, but they dont make a lot of logical sense in entities.
The ef core is some kind new orm library! I think they not gona do some incorect errorrs in conceptual architecture!
Many-to-Many relationships without a linking entity is not incorrect. In fact it makes more sense in an object oriented world because linking entities have no real world parallel. I hate the idea that I have to pollute my domain or use DTOs unnecessarily because my ORM doesn't support this.
Here's a common example. You have courses that have many students. Each student can be in many courses. Classic many-to-many. In a relational database I create a Students table, a Courses table, and a StudentCourses table to link them. In OOP, I would have a Student class and a Course class. I should not have to create a StudentCourse class to link them. It's an artifact of my technology that does not have a parallel in the world I am trying to model.
In EF6.x this easy to set up using the Fluent API:
modelBuilder.Entity<Student>()
.HasMany<Course>(s => s.Courses)
.WithMany(c => c.Students)
.Map(cs =>
{
cs.MapLeftKey("StudentId");
cs.MapRightKey("CourseId");
cs.ToTable("StudentCourse");
});
Could U create ERD diagram with table relationship ? The Third table is need not for modern-fashionable style. 3 table is justified for perfomance and oprtimization purposes!
The current Firebird version database actually still read all record from Disk. 3-rd table this some kind compromise of perfomance vs comfortable usage!
In every RDMS will be perfomance degradation, if u're not using 3-rd table (wtih 2 foreign keys) !
@zanate4019 to your question, the work item for this is https://github.com/aspnet/EntityFrameworkCore/issues/10508.