I was porting an existing .NET code to .NET core.
There is a specific join code that is not working in EFCore. The code is :
var values = (from config in tblConfig
join info in tblInfo on config.No equals info.No
where (
//some conditions
)
select config).ToList();
In EFCore this returns a collection where most of the data are duplicated. Especially, there is a column regNo
which in some cases are "-1". This value is duplicated in all the rows after the join.
I tried the grouping, removing the conditions etc as mentioned in some other post. But didn't work. I am pointing this column since it is easy to understand.
Based on the No
field I need to join. It seems all the empty cells replaced with non-empty content from same table.
In my case I was getting duplicate values ( First row is repeated for all the other rows).
This occurs when we retrieve values from a table having no unique keys. The number of rows returned will be correct but they will be duplicates of the first row. To solve, use AsNoTracking . I got the clue from forums.asp.net
When this is used chances are there that it will miss the Navigation properties. See this answer to fix that.