1
votes

I am using Entity Framework 4.0 with POCO. I add some entities from database, then i rename entity properties. For example i have table "Person" with fields ID, Name. I rename my entity "Person" so:

ID -> PR_ID,

Name -> PR_Name.

Then i create stored procedure:

select * from Person

Then i create function import based on this sp, and specify Entity "Person" as return type. When this function import occurs at run-time i get exception:

{"The data reader is incompatible with the specified 'Model.Person'. 
A member of the type, 'PR_ID', does not have a corresponding column 
in the data reader with the same name."}

here is my questions:

  1. If there is mapping for "Person" entity, which tells convert ID to PR_ID and convert Name to PR_Name, why my function import doesn`t use this mapping?
  2. I can specify aliases for each column in sp, like:
select ID as PR_ID, Name as PR_Name from Person

but is there other solution?

Thank you!

1

1 Answers

0
votes

You need to specify the column names in the stored procedure. If you don't there is no way for the function import to infer the mapping.