1

I am working on a project using entity framework code first approach, I have a situation where I need to call a stored procedure which returns multiple table, hence I want to map the result to my model. please tell me if its possible to do it and if yes then how can i do it.

3
  • Show your code and stored procedure which you have implemented.. Commented Jun 3, 2013 at 9:34
  • 2
    Are you looking for something like that : msdn.microsoft.com/en-us/data/jj691402.aspx ? Commented Jun 3, 2013 at 9:34
  • Thank, i want to know if it works fine with code first Commented Jun 3, 2013 at 9:37

2 Answers 2

1

Code First currently only supports mapping to tables. This unfortunately means that you can’t map Code First directly to stored procedures, views, or other database objects. If you are letting Code First generate a database, there is no way to create these artifacts in the database, other than manually adding them once Code First has created the database. If you are mapping to an existing database, there are some techniques you can use to get data from non-table database artifacts.

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

Comments

1

i am also facing the same problem and not able to get any solution, so i called stored procedure using ExecuteReader and then mapped it to models using autoMapper.

Let me know if you are looking for code

1 Comment

Thanks, I will try to implement it

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.