1
I’m having trouble mapping the Interface IClienteRepository with class ClienteRepository. When compiling the application, this error appears:
"Exception {"To be Able to use the Lifestyle.Scoped Property, Please ensure that the container is configured with a default scoped lifestyle by Setting the Container.Options.Defaultscopedlifestyle Property with the required scoped lifestyle for your type of application. See: https://simpleinjector.org/lifestyles#scoped"} System.Invalidoperationexception"
How to solve?
public static Container RegisterServices(Container container)
    {
        //Domain to Repository
        container.Register<IClienteRepository, ClienteRepository>(Lifestyle.Scoped);
        return container;
    }
public interface IClienteRepository : IRepository<Cliente>
    {
    }
public class ClienteRepository : Repository<Cliente>, IClienteRepository
    {
        public ClienteRepository(SistemaComercialContext context)
            :base(context)
        {
        }
    }
						
That’s not the same one I answered you yesterday
– Pablo Tondolo de Vargas
Possible duplicate of Problems with a Dependency Injection Container - Simple Injector
– Pablo Tondolo de Vargas
similar problem, but now it is another situation involving Interface and class...
– Master JR
From what I’m reading in the documentation, after registering all the dependencies in the container, they call a
container.Verify()and do not pass theLifestyle, getting something like the Registercontainer.Register<IClienteRepository, ClienteRepository>();– Pablo Tondolo de Vargas
I believe that to use the scope you set, you have to make the following call after instantiating the container
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();– Pablo Tondolo de Vargas