I am not sure if this is related to this thread, but I just created a simple EF6 project and am running into problems trying to get an ObjectContext out of a dbContext. I need to do this in order to open and close the database as I have been doing with EF5 as follows:
while (((IObjectContextAdapter)dbContext).ObjectContext.Connection.State.ToString() != "Open")
try
I am also using the ObjectContext to execute SQL. What is the recommended method to do this with EF6?
Thanks
Manish
while (((IObjectContextAdapter)dbContext).ObjectContext.Connection.State.ToString() != "Open")
((IObjectContextAdapter)dbContext).ObjectContext.Connection.Open();
andtry
{
((IObjectContextAdapter)dbContext).ObjectContext.Connection.Close();
}
finally
{
((IObjectContextAdapter)dbContext).ObjectContext.Connection.Dispose();
}
How can I do it? Alternately, is there a different recommended method to accomplish this now?I am also using the ObjectContext to execute SQL. What is the recommended method to do this with EF6?
Thanks
Manish