views:

1197

answers:

2

Using VS 2008, SQL Server 2008 and WPF 3.5, I've made some changes to my schema and updated the model. It compiles and runs fine, until the client app calls for a specific entity and I get the following (actual names replaced):

The data reader is incompatible with the specified '<Model>.<ViewBasedEntity>'. A member of the type, '<Property>', does not have a corresponding column in the data reader with the same name.

I've searched through the services app for related entity and property names, tried renaming properties in the Table Map, Seems to be a number of others out there reporting the same error, but can't seem to find a timely answer....

...Does anyone know how to track this down, and if so, is there a fix or methodology to follow to avoid in the future?

+1  A: 

Please check this blog post. Check first comment by Divan Moller. Might be helpful to you.

Mahin
Thanks Mahin - in this case, the names are identical in case and everything. Following the next comment on that link, perhaps someone can look up Chapter 13 of the Entity Framework Bible mentioned - I don't have a copy.
erinql
+2  A: 

Ok - here's the skinny:

That particular view was setup as a Return Type for a Stored Procedure that had to be setup as a Function Import in the Model's Entity Container.

I had updated that view to fit new reporting requirements, not realizing it's significance to the Function Import. The additional fields are not part of the data set recognized for this purpose, so it couldn't find a match for any of them.

So I duplicated the view and suffixed it with 'Report', then reverted the original back to it's expected set of return fields.

Voila!

erinql
I had a similar issue, then seeing a mention of 'Stored Procedure' reminded me what was the cause.
Nick Josevski