public static IServiceCollection AddTenantContext <TContext, TProvider>(this IServiceCollection services, Action <RepositoryOptions> options = null)
            where TContext : CoreContext
            where TProvider : class, ITenantProvider
        {
            var repositoryOptions = new RepositoryOptions();

            options?.Invoke(repositoryOptions);

            services.AddDbContext <TContext>(repositoryOptions.Builder());

            services.AddScoped <TContext>();
            services.AddScoped <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped <ITenantProvider, TProvider>();

            return(services);
        }
        public static IServiceCollection AddContext <TContext>(this IServiceCollection services, Action <RepositoryOptions> options = null)
            where TContext : CoreContext
        {
            var repositoryOptions = new RepositoryOptions();

            options?.Invoke(repositoryOptions);

            services.AddDbContext <TContext>(repositoryOptions.Builder());

            services.AddScoped <CoreContext, TContext>();
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.AddScoped(typeof(IRepository <,>), typeof(Repository <,>));
            services.AddScoped(typeof(IReadRepository <,>), typeof(Repository <,>));
            services.AddScoped(typeof(IWriteRepository <,>), typeof(Repository <,>));

            return(services);
        }