Thanks for all the answers above!
by the way, we just managed to find a solution that should explicitly use EntityConnection and EntityTransaction. An example is this:
string theSqlConnStr = "data source=TheSource;initial catalog=TheCatalog;persist security info=True;user id=TheUserId;password=ThePassword"; EntityConnectionStringBuilder theEntyConnectionBuilder = new EntityConnectionStringBuilder(); theEntyConnectionBuilder.Provider = "System.Data.SqlClient"; theEntyConnectionBuilder.ProviderConnectionString = theConnectionString; theEntyConnectionBuilder.Metadata = @"res://*/"; using (EntityConnection theConnection = new EntityConnection(theEntyConnectionBuilder.ToString())) { theConnection.Open(); theET = null; try { theET = theConnection.BeginTransaction(); DataEntities1 DE1 = new DataEntities1(theConnection); //DE1 do somethings... DataEntities2 DE2 = new DataEntities2(theConnection); //DE2 do somethings... DataEntities3 DE3 = new DataEntities3(theConnection); //DE3 do somethings... theET.Commit(); } catch (Exception ex) { if (theET != null) { theET.Rollback(); } } finally { theConnection.Close(); } }
with the explicit use of EntityConnection and EntityTransaction, I can achieve the sharing of a single connection and transaction for several ObjectContext objects for the same database, but without the need to use MSDTC.
We hope you find this information helpful. Good luck to you!
source share