1

I am working on upgrading an ASP.Net Web Forms application to MVC + EF Web Application.

I am more or less clear about the MVC part but seems to be a bit stuck about the EF part.

Since its a upgrade so there already exists a DB with lot of stored procedures, functions and other things and I would like to keep them.

For EF Code First from DB is the prefered option as it generates the Model classes automatically.

I am struggling to conceptualize how this will actually work.

for example:

I have two tables Employee & Salary as

enter image description here enter image description here

There is a stored procedure getEmployeeDetails which returns a cursor with properties from both tables.

I am not sure how to map this in DbContext as what I have read so far is that you can map stored procedure to a single mode and not two or more.

Can someone please suggest what can do done here and what will be the best option in terms or using EF code first with existing procedures.

Thanks!!!

niklodeon
  • 1,320
  • 5
  • 20
  • 51
  • EF can create a complex type based on the output of your procedure, in your case `getEmployeeDetailsResult` It will have all the columns that come out of the procedure as properties. However they will not be auto-magically mapped to the table-based objects that EF generates. – Max Sorin Mar 31 '16 at 20:01
  • great! could you kind enough to show or point to a basic example on how to create the DbContext for complex stored procedures and mapping them to models... – niklodeon Mar 31 '16 at 20:08
  • is [this](https://msdn.microsoft.com/en-us/data/jj691402.aspx) how I need to do it? infact this returns multiple result sets and not a complex result set. – niklodeon Mar 31 '16 at 20:12
  • http://stackoverflow.com/questions/32437266/ado-net-entity-data-model-missing-visual-studio-2015-community – Max Sorin Mar 31 '16 at 20:18
  • I could not find anything explaining about using complex stored procedures and mapping multiple models in the link provided by you. Did I miss something. Also I have basic understanding of entity framework.. – niklodeon Mar 31 '16 at 20:27

0 Answers0