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

twig - Using Twigbridge in a Laravel 5.1 Package -

php - Symfony 2: "No route found for "GET /" - error on fresh installation -

java - Openshift port-forwarding -