IDbConnectionFactory implementation dotConnect Oracle?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
jesuissur
Posts: 12
Joined: Wed 13 Oct 2010 14:28

IDbConnectionFactory implementation dotConnect Oracle?

Post by jesuissur » Wed 30 Mar 2011 13:24

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 04 Apr 2011 13:35

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();

Post Reply