Wednesday, 12 February 2014

Entity Framework result set not correct

This is a common problem that most of the people run into. You create an entity model to your view or table. Create a domain service and the client side code. In the client side code you put the filter and you run expecting to get some data but you end up getting one or few rows. I ran into the same problem yesterday. When I ran the program I got just the first row of the expected result.
The problem in my case, when I created the model from my table, I made some changes to attributes, removed bunch of columns, while doing it, i removed the unique key that identified the rows. It seems that if Entity Framework can not uniquely identify the rows, it does not return all the rows. To fix it, all I had to do is, go back to the model, make the fields that uniquely identify the rows, recompile and that’s it.
So if you run into any situation where the rows are not coming properly, this may be one of the culprit.

0 comments:

Post a Comment