Weird error: Unable to determine the DbProviderFactory type

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
hspecht74
Posts: 3
Joined: Wed 24 May 2017 13:32

Weird error: Unable to determine the DbProviderFactory type

Post by hspecht74 » Fri 26 May 2017 05:28

Hello,

I have several projects using EF with PostgreSQL. A few days ago, all projects started to throw an error when trying to access the database with the following error:

"Unable to determine the DbProviderFactory type for connection of type 'Devart.Data.PostgreSql.PgSqlConnection'. Make sure that the ADO.NET provider is installed or registered in the application config."

The databases are ok, I can access them without any problems with pgAdmin. I haven´t installed any updates for postreSQL or the devart stuff.

A windows update has been installed by our IT department (Win7 Professional), but until now it seems I´m the only one experiencing the problem.

I have tried to fix the problem by reinstalling the devart stuff (V 7.3.333) - the problem still exists. Since the problem affects all of my projects, it seems to be a general issue on my machine, but I don´t know where to search...any ideas?

Thanks in advance,

Hinrich

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Weird error: Unable to determine the DbProviderFactory type

Post by Shalex » Fri 26 May 2017 20:14

1. Please specify the full stack trace of the error with all inner exceptions.
2. Tell us the version (x.x.x) of EntityFramework package used by your projects.

hspecht74
Posts: 3
Joined: Wed 24 May 2017 13:32

Re: Weird error: Unable to determine the DbProviderFactory type

Post by hspecht74 » Mon 29 May 2017 04:48

Here´s the stack trace (no inner exception):
System.NotSupportedException occurred
HResult=-2146233067
Message=Unable to determine the DbProviderFactory type for connection of type 'Devart.Data.PostgreSql.PgSqlConnection'. Make sure that the ADO.NET provider is installed or registered in the application config.
Source=EntityFramework
StackTrace:
bei System.Data.Entity.Infrastructure.Net40DefaultDbProviderFactoryResolver.<>c__DisplayClass5.<GetProviderFactory>b__0(Type t)
bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
bei System.Data.Entity.Infrastructure.Net40DefaultDbProviderFactoryResolver.GetProviderFactory(DbConnection connection, IEnumerable`1 dataRows)
bei System.Data.Entity.Infrastructure.Net40DefaultDbProviderFactoryResolver.ResolveProviderFactory(DbConnection connection)
bei System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderFactory(DbConnection connection)
bei System.Data.Entity.Core.Common.DbProviderServices.GetProviderFactory(DbConnection connection)
bei System.Data.Entity.Internal.ClonedObjectContext..ctor(ObjectContextProxy objectContext, DbConnection connection, String connectionString, Boolean transferLoadedAssemblies)
bei System.Data.Entity.Internal.InternalContext.UseTempObjectContext()
bei System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
bei System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c)
bei System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
bei System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
bei System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
bei System.Data.Entity.Internal.InternalContext.Initialize()
bei System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
bei System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
bei System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
bei System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
bei System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
bei Marvin.Resources.Management.ResourceItemMapper.Start() in d:\Jenkins\workspace\AbstractionLayer-CI\Resources\Marvin.Resources.Management\Resources\ResourceItemMapper.cs:Zeile 38.
InnerException:

EntityFramework version is 6.0.0.0
All affected projects are built against .Net framework 4.5.2

Regards,

Hinrich

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Weird error: Unable to determine the DbProviderFactory type

Post by Shalex » Mon 29 May 2017 10:17

1. Try running your Visual Studio (or application itself) via its Run as administrator menu.

2. Is this entry available in your C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config ? Or it is specified in your app.config?

Code: Select all

<configuration>
  <system.data>
    <DbProviderFactories>
     <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version=7.3.333.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> 
    </DbProviderFactories>
  </system.data>
</configuration>
3. Create a simple console application and run this code. Does it work? If not, tell us the exact text of the error and its stack trace.

Code: Select all

    var factory = System.Data.Common.DbProviderFactories.GetFactory("Devart.Data.PostgreSql");
    var conn = factory.CreateConnection();
    conn.ConnectionString = "server=db;port=5441;uid=postgres;pwd=postgres;database=alexsh2;";
    conn.Open();

hspecht74
Posts: 3
Joined: Wed 24 May 2017 13:32

Re: Weird error: Unable to determine the DbProviderFactory type

Post by hspecht74 » Mon 29 May 2017 11:01

Thanks for your reply,

I tried the things you suggested, results:
- Running VS as Administrator makes no difference
- the provider config is present in the machine.config
- Running the code from a console application works fine

So it seems that the problem is not caused by the devart components, more likely there´s a problem in the application framework that is used by all my projects being affected.

Thanks,

Hinrich

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Weird error: Unable to determine the DbProviderFactory type

Post by Shalex » Tue 30 May 2017 07:25

Please add the following entry to *.config of your application and notify us about the result:

Code: Select all

<configuration>
  <system.data>
    <DbProviderFactories>
     <remove invariant="Devart.Data.PostgreSql" />
     <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version=7.3.333.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> 
    </DbProviderFactories>
  </system.data>
</configuration>

Post Reply