You can supply your DataContext with your own database transaction when your application has already initiated the transaction and you want your DataContext to be involved.
The preferred method of doing transactions with the .NET Framework is to use the TransactionScope object. By using this approach, you can make distributed transactions that work across databases and other memory-resident resource managers. Transaction scopes require few resources to start. They promote themselves to distributed transactions only when there are multiple connections within the scope of the transaction.
Using ts As New TransactionScope()
db.SubmitChanges()
ts.Complete()
End Using
using (TransactionScope ts = new TransactionScope())
{
db.SubmitChanges();
ts.Complete();
}
You cannot use this approach for all databases. For example, the SqlClient connection cannot promote system transactions when it works against a SQL Server 2000 server. Instead, it automatically enlists to a full, distributed transaction whenever it sees a transaction scope being used.