I have been searching the web since yesterday but cannot find an example which may solve my issue.
I am trying open and close the connection manually with the below code
Using conn = New EntityConnection(entityBuilder.ToString)
Using ctx As New EbosEntities()
conn.Open()
The problem is, how do i write a constructor(Entity Class) which will take the conn as parameter? otherwise this connection will have nothing to do with the (new context) declaration, I guess. Like below,
ctx As New EbosEntities(conn)
If I want to use default connection string can I just write
ctx.Database.Connection.Open()
Many Thanks.
I don't know how to do it on VB, but with C# you can try to do something like this:
var datacontext = new EbosEntities();
try
{
datacontext.Connection.Open();
//do some work
}
finally
{
datacontext.Connection.Close();
}