Thanks sir for your response, I checked the above implementations.
Specifically the guy that used Middleware to implement a sample is actually on track. But he didn't specify how to add the service and also pass it on the Middleware pipeline.
Am getting error on my program.cs.
It is saying Cannot resolve scoped service "My Project Name". Application DbContext from root provider
The error Happen when I add my EF code to implement count but it doesn't if I remove the code. The error is at the line of CreateBuilder(args).Build(); in the Program.cs