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.

Technorati Tags: ,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s