Page 1 of 1

IDbConnectionFactory implementation dotConnect Oracle?

Posted: Wed 30 Mar 2011 13:24
by jesuissur
Hi there,

In the new Entity Framework 4.1, there's a property on the DbContext class to set the DefaultConnectionFactory (type System.Data.Entity.Infrastructure.IDbConnectionFactory).

To our comprehension, it is required to have a specific provider's implementation to build a new instance of DbContext with a connection string.

We would like to know if there's an implementation for this in the latest dotConnect for Oracle (6.10.126 23-Mar-11).

If not, any tips on how we could easily implements this for Oracle's dotConnect?

Thank you
Phil

Posted: Mon 04 Apr 2011 13:35
by AndreyR
Try something like this code:

Code: Select all

  public class OracleConnectionFactory: IDbConnectionFactory {

    public DbConnection CreateConnection(string nameOrConnectionString) {

      if(!string.IsNullOrEmpty(nameOrConnectionString))
        return new Devart.Data.Oracle.OracleConnection(nameOrConnectionString);
      else 
        throw new ArgumentNullException("ConnectionString");
    }
  }
Then just add this line of code before instantiating the context:

Code: Select all

System.Data.Entity.Database.DefaultConnectionFactory = new OracleConnectionFactory();