Fervent Coder

Coding Towards Utopia...by Rob Reynolds
posts - 278 , comments - 431 , trackbacks - 0

My Links


Rob Reynolds

Subscribe to Fervent Coder RSS
Subscribe to Fervent Coder by Email

About Me

I manage several open source projects. Need...
   ...package management for Windows?
   ...automated builds?
   ...database change management (migrations)?
   ...your application to check email?
   ...a monitoring utility?

I also write for

Like what you are reading? Want to buy me a cup of coffee?
PayPal - The safer, easier way to pay online!


Post Categories


Entity Framework and Stored Procedures Issue - Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values

When working with EF Database First (don’t ask) and mapping stored procedures you may run into this issue.

Julie Lerman has written a great story on how to do the mappings and has some code to download to inspect how to set up the mappings for insert, update, and delete appropriately for use with stored procedures (http://msdn.microsoft.com/en-us/data/gg699321.aspx).

You may have searched everywhere else and have not been able to find a satisfactory answer. In some cases your model has a circular dependency and there are multiple search results that will help you with that out there.

In my case the problem came down to using a Manage type sproc that would handle both insert and update. As you can imagine you would pass in the primary key field to the Sproc no matter what.

Entity Framework believes this is an association (possibly to a foreign key) so it gives the error above. When you convert it to using separate Insert and Update stored procedures where the insert does not pass in the PK, everything works appropriately.

So if you are getting the above error, make sure you are not mapping the PK in the insert procedure.

Hope this helps some poor soul who falls upon this issue.

Print | posted on Wednesday, August 15, 2012 1:36 PM |


Comments are closed.
Comments have been closed on this topic.

Powered by: