2

I have the following Entity Framework model:

Entities

It's a very simple model and was working fine when Entity Framework was generating the SQL. When I mapped the entities to stored procedures I get the following error when trying to create a LogEntry:

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

The code I am using to make a LogEntry looks like the following:

le.DateAndTime = DateTime.Now;
le.User = (Guid)Membership.GetUser().ProviderUserKey;

Log log = lr.GetLog(le.LogId);
log.LogEntries.Add(le);

lr.Save(); // lr is an instance of LogsRepository, defined earlier in the class

The exception isn't thrown until lr.Save() is called.

Can anybody help me decipher this? I have stored procedures which all work on their own, independent of entity framework, mapped to the entities.

2 Answers 2

2

I managed to figure out what was causing the error. Take a look at the following mapping setup:

Log Mapping

As you can see, I had a result column binding from UpdateLog, problem being that UpdateLog doesn't return anything. I accidentally put this into the mapping. After deleting the result column binding everything works again.

Sign up to request clarification or add additional context in comments.

Comments

0

It doesn't look like you're using the stored procedure. If you add a function import for the procedure, you can call the function import directly on the context.

1 Comment

I mapped the stored procedures to the entities in the entity designer according to the following screenshots: imgur.com/a/em6YK This has worked fine in the past. I only use function imports for select operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.