In EF6 we subscribe to the DbConnection.StateChange event to keep the State of EntityConnection and the underlying StoreConnection in sync. However if the custom DbConnection does not correctly fire the event the state of the EntityConnection is different from the state of the underlying store connection provided by user. In this case we will first assert in the EnsureContextIsEnlistedInCurrentTransaction method (see below) and then throw an InvalidOperationException saying "The connection is not open.". The message can be surprising since when the user looks at his connection it is actually open and also if you set breakpoints on Open() and Close() methods you will see that Open() was called but Close() was not. We throw the exception since this the EntityConnection whose state is closed. Note that before EF6 we did not use the StateChange event, so if someone is trying to move an EF5 project that was using a wrapping provider to EF6 he will very likely hit this issue. We should replace the assert with an exception hinting that a correct implementation StateChange is required.
In this case is there an error, or a wrong implementation on Devart DotConnect, or my code? Should I handle this connectionstate or do you guys have to patch this ?