Page 1 of 1

Solve issue with PgSqlEntityProviderServicesConfiguration being discovered too late

Posted: Thu 15 Nov 2018 23:04
by peter.jim
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

Re: Solve issue with PgSqlEntityProviderServicesConfiguration being discovered too late

Posted: Fri 16 Nov 2018 10:16
by Shalex
Thank you for sharing your experience.

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