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

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -