views:

55

answers:

0

I have a SQL View (SQL Server 2008) that contains 4 columns and works just fine in SSMS. I added the SQL View via Database Update to my Entity Framework model. No complaints, but I noticed that EF decided to make 2 of the 4 columns EntityKeys.

The problem I'm having is that when I run the query in my app code, I get the right number of rows back (compared to direction query execution in SSMS), but some rows have incorrect values for 1 of the columns that's not marked as an EntityKey. Looking more closely, it appears that EF maintains the first non-EntityKey column's value for all subsequent results rows that have the same column values in the 2 columns marked as EntityKey.

At first I thought to fix this by marking the 3rd column as an EntityKey. But then compliation fails with a complaint that the data model mapping is not an EntityKey (which is of course, correct).

Any ideas for how to work around this?