How to make db context reachable in the whole project, when using EF connection string built at runtime.
How to make db context reachable in the whole project, when using EF connection string built at runtime ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 31, 2012, 12:56 PM
SamioPosted May 31, 2012, 1:32 PM
SamioPosted May 31, 2012, 7:54 AM
In my connection form I have this:
using (EntityConnection conn = new EntityConnection(Global.Cnx))
{
conn.Open();
using (var ctx = new Entities(conn))
{
var qry = ...
}
conn.Close();
}
I need to use ctx in the whole project, how can I declare it as Global since public static var is not accepted.
it is there a disadvantage in terms of safety and performance if it is used in this way.
Jaish MathewsPosted May 31, 2012, 7:00 AM