【发布时间】:2011-05-13 21:42:25
【问题描述】:
由于here 所述的原因,我需要多次调用 SaveChanges。我希望将这两个调用都包含在一个事务中(这样如果第二个调用失败,第一个调用将回滚)。例如:
AccountsContext context = new AccountsContext(connectionString);
CountryNotes notes = new CountryNotes();
notes.Notes = "First save";
context.SaveChanges();
notes.Notes = "Second save";
context.SaveChanges();
如何将上述两个 SaveChanges 调用放在一个事务中?
谢谢,
保罗。
【问题讨论】:
标签: transactions ef-code-first entity-framework-4.1