Pomster
Pomster

Reputation: 15207

The data reader is incompatible with the specified... A member of the type, 'Finalised', does not have a corresponding column in the data reader

I have added a column in my Sql Server Db then in VS i updated model from database, there a template auto generated some code.

The code compiled fine, but when i try access a the data base, the following error occurs:

The data reader is incompatible with the specified 'CompassModel.tbSalesContract'. A member of the type, 'Finalised', does not have a corresponding column in the data reader with the same name.

Finalised is the new column i added to my database.

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

Upvotes: 2

Views: 18917

Answers (3)

hanesjw
hanesjw

Reputation: 2584

Hopefully this helps someone out but when I received this error I was trying to return an entity type from a stored procedure.

To fix this I had to add the correct function import mapping. In your edmx go to the Model Browser view and navigate to Funtion Imports. Right click your sproc name and select function import mapping. There you can map your sproc return results to the appropriate entity property.

Upvotes: 0

criss thomas
criss thomas

Reputation: 1

If you are using a SP, then please make sure the alias names used.. ie. for eg: It should be written as

fieldname as 'aliasname'

thanks, criss thomas

Upvotes: 0

PandeyTheDBA
PandeyTheDBA

Reputation: 76

If you are using a SP then update the newly added column in that Or If you are using inline query put the exact name of the newly added column . The template you are talking about does not contain the newly added column name ..Try to edit the template ..the issue will be resolved.

Upvotes: 6

Related Questions