-
-
Notifications
You must be signed in to change notification settings - Fork 65
Description
I use it like this:
builder.Services.AddDbContext<AppDbContext>(options => options
.UseSqlServer(builder.Configuration.GetConnectionString("DB"))
.AddDelegateDecompiler()
);
And have projections like this:
[Decompile]
public static LookupDto ToStatusResponseDto(this StatusEntity model)
{
return new LookupDto
{
Id = model.Id,
Name = model.StatusName
};
}
After calling projection couple of times, I get this error:
System.InvalidOperationException: 'An error was generated for warning 'Microsoft.EntityFrameworkCore.Infrastructure.ManyServiceProvidersCreatedWarning': More than twenty 'IServiceProvider' instances have been created for internal use by Entity Framework. This is commonly caused by injection of a new singleton service instance into every DbContext instance. For example, calling 'UseLoggerFactory' passing in a new instance each time--see https://go.microsoft.com/fwlink/?linkid=869049 for more details. This may lead to performance issues, consider reviewing calls on 'DbContextOptionsBuilder' that may require new service providers to be built. This exception can be suppressed or logged by passing event ID 'CoreEventId.ManyServiceProvidersCreatedWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.'
Do you recognize incorrect usage? How to fix the issue?