I took a look at other related posts but couldn't find any solution.
Sometimes on sesstion.Flush() I get the following error:
{"could not execute batch command.[SQL: SQL not available]"}
and the Inner Exception :
{"The UPDATE statement conflicted with the FOREIGN KEY constraint FK1377052553ABF955. The conflict occurred in database ProcessDebug, table dbo.Adjustment, column 'AdjustmentId'.The statement has been terminated."}
a piece of Process class mapping :
References(p => p.CurrentAdjustment)
;
References(p => p.DefaultAdjustment)
;
HasMany(p => p.Adjustments)
.Cascade.AllDeleteOrphan()
.Inverse()
;
All these properties above are of type of Adjustment. As long as I get this error once in a while I couldn't track it down. For an entity it might happen now, but not next time in a same piece of code....
Any idea what might cause the problem?
I'm using NH 3.2 and FluentNhibernate
Thanks in advance
In my situation, it was "NULL" in one of the databese columns. Check your database data.
FOREIGN KEY -> this means, that you propably have null i column, that is use for "join".
p.s. Take SQL Profiler and check the SQL generated by nHibernate.
You need to look at the sql that is actually trying to execute.
It appears as though you are trying to update the primary key ("AdjustmentId") to something that does not exist. Hence the foreign key violation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With