views:

32

answers:

1

I have tables named Contact and Address and both of them have "ModifiedDate" column. I have written the CUD operations using Stored procedures. However, when It came to SELECT stored procedure in which I needed to return all the contacts with their addresses, I got an error.

System.Data.EntityCommandExecutionException: The data reader is incompatible with the specified 'AddressBookModel.SelectAllContactsWithAddresses_Result2'. A member of the type, 'ModifiedDate1', does not have a corresponding column in the data reader with the same name.

I ended up changing the stored procedure to return different aliases for those column name and more unfortunately, I needed to change the properties in the entities in the model as well to match the selected column. I wrote a blog post about this here. I know I could have separate select SPs (and separate function imports) for both the entities but this is just one situation and can happen in other cases as well where same columns names might get returned from a complex query from multiple tables in a SP. Could anybody provide any direction on this?

+1  A: 

I posted the same question in the MS forums for EF here (sorry for the cross posting) and the moderator confirmed that this is a bug in EF and asked me to create a bug in the Microsoft Connect and the bug Id is 597376 and here is the link for the same.

from Lingzhi Sun MSFT, Moderator Support in Forum>

Hello,   After some research and test,
> I can repro this issue at my side.  
> It can be a limitation of EF when
> handling stored procedure return
> values.  I would recommend you open a
> ticket at Microsoft Connect to report
> this issue to the product team.   If
> it is convenient, please share us with
> the ticket link here to benefit more
> community members.  
ydobonmai