4

I have a stored procedure that search a view using full text.
I'm trying to map the results to an existing Entity (Sales), where I mapped the column MivType to SaleType (as it makes more sense, and I want to keep db names away from my web site). The stored procedure is mapped to a Function Import, and I've defined its ReturnType to Sales.
This work well as long as the entity has the same property names as fields names.

Here's my problem: when I change the property's name, I get the following error after running the imported function:

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

I can fix this if I change the property 'SaleType' to 'MivType' on the entity, but why should I do that? Isn't that what the mapping is for?
This means I have to use the exact same names on the stored procedure and the entity, so in effect, the mapping is ignored (I have names like YzrName, MivYaad, etc, and I don't like it).
Is there a simple way around this? I don't want to use the db names on my application, and prefer not to change the stored procedure...
(I should mention I'm a beginner with the EF, so this can be a rookie mistake)

Thanks.

1 Answer 1

4

Well the entity designer doesnt work very well. I generally try to do everything in the XML. In the XML there are 3 parts. The Storage (a representation of the SQL Database). The Conceptual (a represention of your .Net Objects. and the Conceptual to Storage Mapping

It sounds like the error is in your Conceptual to Storage Mapping. You can keep the property name SalesType on the conceptual side but the mapping must map the the correct names on both the conceptual and storage side.

Refer to MSDN here are some articles http://msdn.microsoft.com/en-us/library/cc716731.aspx

Sign up to request clarification or add additional context in comments.

3 Comments

I'll accept the answer because the EF designer doesn't work well, at all, but I'm not sure I can fix that one by XML. Unfortunately, I don't have the time to confirm that atm.
@Kobi Do you have a solution for this issue.? I am facing the same problem in my project.Please suggest me...I know this is too late to ask..
@user1882705 - Unfortunately I don't have a real solution - I stayed with the ugly names. Also, the project got canceled. But - this question is over 3 years old, I hope that bug is fixed by now. Entity Framework is now on version 6. Sorry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.