I'm working with Oracle.ManagedDataAccess
(v. 4.122.19.1) and Entity Framework (v. 6.0.0.0).
I created a simple context like this:
public class FooContext : DbContext
{
public FooContext() : base(new OracleConnection(Connection.connection),true)
{
Database.SetInitializer<FooContext>(null);
Configuration.LazyLoadingEnabled = false;
}
}
and test method:
[TestMethod]
private static void TestIsConnectionOpen()
{
using (var db = new FooContext())
{
Assert.AreEqual(ConnectionState.Open, db.Database.Connection.State);
}
}
I expected, that in this case, connection will be automatically open, like in this e.g. https://github.com/entityframeworktutorial/EF6-DBFirst-Demo , but the test fails.
Could someone explain to me why?
Connection.connection
is a valid connection string, because when I change test method to:
[TestMethod]
private static void TestIsConnectionOpen()
{
using (var db = new FooContext())
{
db.Database.Connection.Open();
Assert.AreEqual(ConnectionState.Open, db.Database.Connection.State);
}
}
then the test passed.