E
E
Evgeny Semashko2021-08-01 18:33:01
.NET
Evgeny Semashko, 2021-08-01 18:33:01

Why doesn't EF Core output all data on JOIN?

I have such query for My SQL

SELECT Project.name AS Project, Test.name AS Test, ROUND(TIME_TO_SEC(timediff(Test.end_time, Test.start_time))/60) AS MIN_WORKING_TIME
FROM Project
INNER JOIN Test ON Test.project_id = Project.id

And this query displays 345 rows in My SQL Workbench , as well as a screen with data output.

A similar query for EF Core and this database
var projectsAndTests = db.Projects.Join(db.Tests,
                    p => p.Id,
                    t => t.Id,
                    (p, t) => new
                    {
                        project = p.Name,
                        test = t.Name,
                        MIN_WORKING_TIME = t.EndTime - t.StartTime
                    });

This code gives me only 6 queries , that is, according to the principle of 1 company, one test for it, but it needs to be like in My SQL.

The models in the code are built using the DB First approach, i.e. I just did Scaffold
. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Station 72, 2021-08-01
@evgenysemashko

You need to see what SQL query EF Core generates and only then see how they differ.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question