Creating new Entities from Stored Procedure
- by SK
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?