private static void PreConfigure <TDbContext>(
            AbpDbContextOptions options,
            AbpDbContextConfigurationContext <TDbContext> context)
            where TDbContext : AbpDbContext <TDbContext>
        {
            foreach (var defaultPreConfigureAction in options.DefaultPreConfigureActions)
            {
                defaultPreConfigureAction.Invoke(context);
            }

            var preConfigureActions = options.PreConfigureActions.GetValueOrDefault(typeof(TDbContext));

            if (!(preConfigureActions == null || preConfigureActions.Count <= 0))
            {
                foreach (var preConfigureAction in preConfigureActions)
                {
                    ((Action <AbpDbContextConfigurationContext <TDbContext> >)preConfigureAction).Invoke(context);
                }
            }
        }
        public static DbContextOptions <TDbContext> Create <TDbContext>(IServiceProvider serviceProvider)
            where TDbContext : AbpDbContext <TDbContext>
        {
            var creationContext = GetCreationContext <TDbContext>(serviceProvider);

            var context = new AbpDbContextConfigurationContext <TDbContext>(
                creationContext.ConnectionString,
                creationContext.DatabaseProvider,
                serviceProvider,
                creationContext.ConnectionStringName,
                creationContext.ExistingConnection
                );

            var options = GetDbContextOptions <TDbContext>(serviceProvider);

            PreConfigure(options, context);
            Configure(options, context);

            return(context.DbContextOptions.Options);
        }
        private static void Configure <TDbContext>(
            AbpDbContextOptions options,
            AbpDbContextConfigurationContext <TDbContext> context)
            where TDbContext : AbpDbContext <TDbContext>
        {
            var configureAction = options.ConfigureActions.GetValueOrDefault(typeof(TDbContext));

            if (configureAction != null)
            {
                ((Action <AbpDbContextConfigurationContext <TDbContext> >)configureAction).Invoke(context);
            }
            else if (options.DefaultConfigureAction != null)
            {
                options.DefaultConfigureAction.Invoke(context);
            }
            else
            {
                throw new Exception(
                          $"No configuration found for {typeof(DbContext).AssemblyQualifiedName}! Use services.Configure<AbpDbContextOptions>(...) to configure it.");
            }
        }