实体框架由Savechanges()生成的顺序sql [英] Entity Framework the order sql generated by Savechanges()
本文介绍了实体框架由Savechanges()生成的顺序sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在上下文中调用SaveChanges时,我正在查看执行的sql,它会按顺序更新,删除和插入sql stament。有没有办法将其更改为删除,更新,插入?
I am looking at the sql executed when I call SaveChanges on context, it does update , delete and insert sql stament in that order.. is there a way to change it to delete , update , insert ?
推荐答案
我可以想到的唯一方法是调用您的 Delete()
首先然后 SaveChanges()
然后执行其余的 Insert()
和 Update )
。不是说这是唯一的方法...
The only way that I can think of is to call your Delete()
first then SaveChanges()
then do the rest Insert()
and Update()
. Not saying that is the only way...
看起来没有办法改变顺序... - DbContext SaveChanges语句执行顺序
Looks like there is no way to change the order... - DbContext SaveChanges Order of Statement Execution
这篇关于实体框架由Savechanges()生成的顺序sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文