Solve issue with PgSqlEntityProviderServicesConfiguration being discovered too late

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
peter.jim
Posts: 1
Joined: Thu 15 Nov 2018 22:54

Solve issue with PgSqlEntityProviderServicesConfiguration being discovered too late

Post by peter.jim » Thu 15 Nov 2018 23:04

I'm just sharing this here so someone else doesn't fall into the same pit.

Occasionally I was getting an exception raised:

Code: Select all

System.InvalidOperationException: 'The default DbConfiguration instance was used by the Entity Framework
before the 'PgSqlEntityProviderServicesConfiguration' type was discovered.
An instance of 'PgSqlEntityProviderServicesConfiguration' must be set at application start before using any
Entity Framework features or must be registered in the application's config file.
See http://go.microsoft.com/fwlink/?LinkId=260883 for more information.'
To fix this, add codeConfigurationType attribute to the web config entityFramework element

Code: Select all

<entityFramework codeConfigurationType="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServicesConfiguration, Devart.Data.PostgreSql.Entity">
This is a more reliable way to determine the Configuration type.

Alternatively, this could have been solve also by adding the DbConfigurationType attribute on the DbContext

Code: Select all

using Devart.Data.PostgreSql.Entity;

namespace IdentityServer3.EntityFramework
{
    [DbConfigurationType(typeof(PgSqlEntityProviderServicesConfiguration))]
    public class BaseDbContext : DbContext
    ...
see details at https://docs.microsoft.com/en-au/ef/ef6 ... code-based

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

Re: Solve issue with PgSqlEntityProviderServicesConfiguration being discovered too late

Post by Shalex » Fri 16 Nov 2018 10:16

Thank you for sharing your experience.

JIC: https://www.devart.com/dotconnect/postg ... rovideref6

Post Reply