Closed pankaj-kansodariya closed 1 month ago
If you still want use the pooled db context with 13, the easiest thing to do is to register the db context on the schema as pooled. RegisterDbContext<FooContext>(Pooled)
. You then do not need any attribute
So if we consider to solve the issue of Parallel execution of DbContext, we have following multiple options
Option 1: If DbContext is registered as Services.AddDbContext() then need to use [Service(ServiceKind.Synchronized)]
Option: 2 If DbContext is registered as Services.AddDbContext() then need to use IRequestExecutorBuilder.RegisterDbContext(DbContextKind.Synchronized) and no need specify [Service] attribute.
Option: 3 If DbContext is registered as Services.AddPooledDbContextFactory() then need to use IRequestExecutorBuilder.RegisterDbContext(DbContextKind.Pooled) and no need specify [Service] attribute.
in that case, which scenario is suitable for using ObjectFieldDescriptorExtensions and UseApplicationDbContextAttribute ?
@pankaj-kansodariya You do not need the UseApplicationDbContextAttribute anymore when you do option 3
If you do not have a pooled db context then you can also just use the DbContextKind.Resolver where we open a DI scope per resolver. But if you already have it set up to use the Pooled version of it, just go for DbContextKind.Pooled and do not worry about UseDbContext and [Service]
It would be helpful to get an updated set of instructions for Session #3, just like @pankaj-kansodariya mentioned.
I am trying to resolve this using option 3, but there doesn't seem to be RegisterDbContext
?
using "HotChocolate.AspNetCore" Version="13.5.1"
solution: Add package HotChocolate.Data.EntityFramework
I'm closing this issue as outdated, as we have an updated workshop on the main
branch, for Hot Chocolate 14.
As per GraphQL-Workshop and Session #3 Understanding GraphQL query execution and DataLoader
I followed Steps 3, 4, 5, 6 & 7 and everything worked as expected. But Warning is shown while using [ScopedService] that it is Obsolete and I should use [Service(ServiceKind.Pooled)] or [Service(ServiceKind.Resolver)]. But when I use either [Service(ServiceKind.Pooled)] or [Service(ServiceKind.Resolver)] then getting error as following.
"No service for type 'Microsoft.Extensions.ObjectPool.ObjectPool`1[ApplicationDbContext]' has been registered."