Page 1 of 1

Database connection not open on creating a dbContext

Posted: Thu 25 Jul 2013 13:56
by HadleyHope
The code we have been using is:

Code: Select all

TSDataContext ctx = new TSDataContext(ProjectConnectionString) { ObjectTrackingEnabled = !readOnly };
Previous to 4.6.287 we could then use ctx strait away in a LINQ or table object query. After upgrading any query now throws a error with the message that the connection is closed.

We have changed our code to:

Code: Select all

TSDataContext ctx = new TSDataContext(ProjectConnectionString) { ObjectTrackingEnabled = !readOnly };
ctx.Connection.Open();
The context is created by Entity Developer creating the model from a database.

But are wondering if a bug has been introduced?

Re: Database connection not open on creating a dbContext

Posted: Fri 26 Jul 2013 09:10
by MariiaI
We couldn't reproduce the "Connection is closed" exception on our environment.
Please specify the stack trace of the exception and send us a sample project, so that we are able to investigate this issue in more details.

Re: Database connection not open on creating a dbContext

Posted: Fri 26 Jul 2013 15:49
by HadleyHope
Thanks for the reply, I created a small sample project, when the context is created the connection is closed, but it does automatically open when a query is made.

Guess it must be something else in our solution that is causing a problem, anyway thanks for looking.


Regards Martin

Re: Database connection not open on creating a dbContext

Posted: Mon 29 Jul 2013 07:58
by MariiaI
HadleyHope wrote: Guess it must be something else in our solution that is causing a problem, anyway thanks for looking.
Please specify the following details:
- the type of your application, where the issue occurs ( Console, ASP.NET WEB, ASP.NET MVC, etc.);
- the full stack trace of the exception;
- some piece of code, where the exception occurs.