After including a view I have in my database in an Entity Framework data model, I noticed that for some strange reason, the result was showing duplicates. When a set should have for instance 10 different rows, it might contain only 4 different rows, some of which were duplicated so it was still a total of 10 rows.
The view itself showed the correct results, but when called from code using the Entity Framework, it once again showed the wrong results.
After some testing I found out that the rows that were duplicated, were rows that shared certain values with the rows that were replaced by it. After checking this in my Entity Model, I soon found at that the Entity Model has a strange way of handling rows with equal primary key values.
I'll try and explain my findings:
A blog about anything a software engineer might encounter during his programming efforts.
Showing posts with label Entity Framework. Show all posts
Showing posts with label Entity Framework. Show all posts
22 November 2011
Entity Framework: duplicate rows in resultset from a view
Labels:
.net
,
C#
,
Entity Framework
,
SQL
Subscribe to:
Posts
(
Atom
)