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
Weird error: Unable to determine the DbProviderFactory type
Re: Weird error: Unable to determine the DbProviderFactory type
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.
2. Tell us the version (x.x.x) of EntityFramework package used by your projects.
Re: Weird error: Unable to determine the DbProviderFactory type
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
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
Re: Weird error: Unable to determine the DbProviderFactory type
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?
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.
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>
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();
Re: Weird error: Unable to determine the DbProviderFactory type
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
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
Re: Weird error: Unable to determine the DbProviderFactory type
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>