Geeks With Blogs

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!

Fervent Coder Coding Towards Rob Reynolds

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 (

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.

Posted on Wednesday, August 15, 2012 1:36 PM | Back to top

Comments on this post: 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

Comments are closed.
Comments have been closed on this topic.
Copyright © Robz / Fervent Coder | Powered by: | Join free