Creating new Entities from Stored Procedure

Posted by SK on Stack Overflow See other posts from Stack Overflow or by SK
Published on 2010-03-12T03:19:48Z Indexed on 2010/03/12 3:27 UTC
Read the original article Hit count: 125

Filed under:
|

I have a stored procedure that retrieves existing rows from a table and also creates includes new rows that match the table definition and mapped entity (.net 3.5 entity framework). These new rows are not written to the database in the stored procedure.

The stored procedure executes, but the new rows that were created will not load the navigation properties sucessfully i.e. the rows that do not actually exist in the database.

e.g.

database rows:

key, data, FK

1, xxx, a

2, xxx, b

returned rows from stored procedure:

key, data, FK

1, xxx, a

2, xxx, b

3, yyy, a

4, yyy, b

The entity will load FK entities a and b for rows 1 and 2, but for rows 3 and 4 the FK entity is null.

Do I somehow need to add the new rows to the data context? or turn off tracking?

© Stack Overflow or respective owner

Related posts about entity

Related posts about framework