Giorgi / EntityFramework.Exceptions

Strongly typed exceptions for Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql.
https://giorgi.dev/entity-framework/introducing-entityframework-exceptions/
Other
1.44k stars 68 forks source link

PooledDbContext #56

Closed FoxTes closed 1 year ago

FoxTes commented 1 year ago

Hello.

I ran into the problem of adding this library when using a context pool.

Registration:

builder.Services.AddPooledDbContextFactory<ApplicationContext>(options => options.UseNpgsql(connectionString));

public class ApplicationContext : DbContext
{
    public ApplicationContext(DbContextOptions<ApplicationContext> options)
        : base(options)
    {
    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseExceptionProcessor();
    }
}

Error: Unhandled exception. System.InvalidOperationException: 'OnConfiguring' cannot be used to modify DbContextOptions when DbContext pooling is enabled.

Giorgi commented 1 year ago

The library works perfectly with DbContext pooling. Either read the documentation for DbContext pooling or Sponsor the Project and I'll provide an example.

FoxTes commented 1 year ago

Well, I didn't expect such an answer. You are making an open source library. Don't you think that this instruction should be added to the readme so that people know how to use it? And not to demand money from them.

Giorgi commented 1 year ago

Your question isn't specific to this library, it can be rephrased as How do I configure DbContext when using DbContext pooling?