/// <summary>
        /// Adds your database context class to the service provider.
        /// Use to configure the DynamoContext options.
        /// </summary>
        /// <typeparam name="TContext">A custom type that implements EasyDynamo.Core.DynamoContext</typeparam>
        /// <param name="services">The service collection.</param>
        /// <param name="configuration">The application configuration.</param>
        /// <param name="optionsExpression">Action over EasyDynamo.Config.DynamoContextOptions.</param>
        public static IServiceCollection AddDynamoContext <TContext>(
            this IServiceCollection services,
            IConfiguration configuration,
            Action <DynamoContextOptions> optionsExpression)
            where TContext : DynamoContext
        {
            InputValidator.ThrowIfNull(optionsExpression);

            var contextOptions = new DynamoContextOptions(typeof(TContext));

            optionsExpression(contextOptions);

            services.AddSingleton <IDynamoContextOptions>(sp => contextOptions);

            services.AddDynamoContext <TContext>(configuration);

            return(services);
        }
        /// <summary>
        /// Adds your database context class to the service provider.
        /// </summary>
        /// <typeparam name="TContext">
        /// A custom type that implements EasyDynamo.Core.DynamoContext.
        /// </typeparam>
        /// <param name="services">The service collection.</param>
        /// <param name="configuration">The application configuration.</param>
        public static IServiceCollection AddDynamoContext <TContext>(
            this IServiceCollection services, IConfiguration configuration)
            where TContext : DynamoContext
        {
            services.EnsureContextNotAdded <TContext>();

            services.AddSingleton <IDependencyResolver, ServiceProviderDependencyResolver>();
            services.AddCoreServices();

            var awsOptions     = configuration.GetAWSOptions();
            var contextOptions = services
                                 .BuildServiceProvider()
                                 .GetRequiredService <IDynamoContextOptionsProvider>()
                                 .TryGetContextOptions <TContext>();

            if (contextOptions == null)
            {
                contextOptions = new DynamoContextOptions(typeof(TContext));

                services.AddSingleton(sp => contextOptions);
            }

            services.AddDefaultAWSOptions(awsOptions);

            var contextInstance = Instantiator.GetConstructorlessInstance <TContext>();

            services.BuildModels(contextInstance, configuration, contextOptions);

            BuildConfiguration(contextInstance, configuration, contextOptions);

            services.AddSingleton <TContext>();
            services.AddSingleton(typeof(IDynamoDbSet <>), typeof(DynamoDbSet <>));

            services.AddDynamoClient(awsOptions, contextOptions);

            contextTypesAdded.Add(typeof(TContext));

            return(services);
        }