This problem is not readily reproducible in a simple example here but was wondering if anyone has any experience and tips, here is the issue:
- using Entity Framework
- have many points in application where (1) data is written to some entity table e.g. Customer, (2) data is written to history table
- both of these actions use Entity Framework, HOWEVER, they use different contexts
- these actions need to be both in one transaction: i.e. if one fails to write, the other should not write, etc.
- I can wrap them with a TransactionScope,
like this:
using (TransactionScope txScope = new TransactionScope()) {
...
}
but this gives me:
Microsoft Distributed Transaction Coordinator (MSDTC) is disabled for network transactions.
Our database admin has told me that MSDTC is disabled by choice and can not be installed.
Hence I am making changes trying to create my own EntityConnection with a MetadataWorkspace with the idea that each context will use the same EntityConnection. However, this is proving near impossible trying to get it to work, e.g. currently I continue to get the above error even though theoretically both contexts are using EntityConnection. It's difficult to understand where/why Entity Framework is requiring the MSDTC for example.
Has anyone gone down this road before, have experience or code examples to share?