This one had me confused for a long time, several hours in fact. There were over 8,000 rows in the table, and the for some reason the query was returning the same row 8,000 times. After much rending of garments and gnashing of teeth, I discovered that the table in question (in a sql server 2000 database (not created by me)) had no primary key defined.
So – I copy the data into a new table, create a key with the commands
alter table TableInQuestion
add NewIDColumn int identity(1,1)
Delete the empty key field (that was what threw me, there was a column named “Id”, which was not actually and ID column.) rename “NewIDColumn” to “Id”, then point EF to the new table with the data attribute (on the object)
[Table(“TableInQuestion”)]
and everything works like a charm