Entity Framework Stored Procedures Exception
I have the following Entity Framework model:
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.
I managed to figure out what was causing the error. Take a look at the following mapping setup:
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.
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.
精彩评论