Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data reader is incompatible... member does not have corresponding column in data reader

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?

like image 513
erinql Avatar asked Sep 29 '09 18:09

erinql


2 Answers

Rather than updating the view, you can also update the Function Import:

  • Go to the Model Browser window
  • Expand the EntityContainer
  • Open the Function Import in the Mapping Details window
  • If the entity name (left column) does not match the expected field name (right column), you can change the right-hand column to match what the returned field is actually called.
like image 190
Calvin Fisher Avatar answered Oct 17 '22 23:10

Calvin Fisher


I had a similar issue which produced the same error message - the problem was that a column name returned by the proc included a space.

When creating the complex type, [my column] was created as my_column.

Then when executing the proc with ExecuteStoreQuery, my_column did not exist in the data reader, as the proc still returned [my column].

Solution: remove the space from proc column name and recreate your complex type for the imported function.

like image 5
JamieA Avatar answered Oct 17 '22 23:10

JamieA