Entity Framework 6: Multiple contexts from same database in 1 transaction -
with 2 different context classes use same database best way include changes both in same transaction?
you can use transactionscope distributed transaction. concept:
using(var transaction = new transactionscope()) { using (var context1 = new dbcontext1()) { ... context1.savechanges(); } using (var context2 = new dbcontext2()) { ... context2.savechanges(); } transaction.complete(); }
only when transactionscope completed (committed), changes reflect in database.
Comments
Post a Comment