kosnkov
kosnkov

Reputation: 5941

Distributed transaction the same connection

Hi I noticed that if I use two edmx , and each one has it's own connection string, but they point to the same database, and server, user and password is the same, then distributed transaction is created. Is it any way to avoid it ?

Upvotes: 1

Views: 85

Answers (1)

Sampath
Sampath

Reputation: 65870

You have to tell EF about the single Database connection. You can do it simply by openning the connection yourself after creating the context.

Like this :

  using (var ctx = new YourEntities())
    {
        ((IObjectContextAdapter)ctx).ObjectContext.Connection.Open();

        //your other code
    }

Upvotes: 1

Related Questions