public static IServiceCollection AddFastData(this IServiceCollection serviceCollection, Action <ConfigData> action)
        {
            config = new ConfigData();
            action(config);

            if (!config.IsResource && DataConfig.Get(config.dbKey, null, config.dbFile).CacheType == CacheType.Redis && ServiceContext.Engine.Resolve <IRedisRepository>() == null)
            {
                throw new System.Exception("ConfigureServices First add services.AddFastRedis(); Second add services.AddFastData()");
            }

            if (DataConfig.Get(config.dbKey, Assembly.GetCallingAssembly().GetName().Name, config.dbFile).CacheType == CacheType.Redis && ServiceContext.Engine.Resolve <IRedisRepository>() == null)
            {
                throw new System.Exception("ConfigureServices First add services.AddFastRedis(); Second add services.AddFastData()");
            }

            serviceCollection.AddSingleton <IFastRepository, FastRepository>();

            Assembly.GetCallingAssembly().GetReferencedAssemblies().ToList().ForEach(a =>
            {
                if (!AppDomain.CurrentDomain.GetAssemblies().ToList().Exists(b => b.GetName().Name == a.Name))
                {
                    try { Assembly.Load(a.Name); } catch (Exception ex) { }
                }
            });

            if (config.aop != null)
            {
                serviceCollection.AddSingleton <IFastAop>(config.aop);
            }

            if (!string.IsNullOrEmpty(config.NamespaceService))
            {
                FastMap.InstanceService(serviceCollection, config.NamespaceService);
            }

            ServiceContext.Init(new ServiceEngine(serviceCollection.BuildServiceProvider()));

            var projectName = Assembly.GetCallingAssembly().GetName().Name;

            if (config.IsResource)
            {
                FastMap.InstanceMapResource(config.dbKey, config.dbFile, config.mapFile, projectName);
            }
            else
            {
                FastMap.InstanceMap(config.dbKey, config.dbFile, config.mapFile);
            }

            if (config.IsCodeFirst && !string.IsNullOrEmpty(config.NamespaceCodeFirst) && config.IsResource)
            {
                FastMap.InstanceProperties(config.NamespaceCodeFirst, config.dbFile, projectName);
                FastMap.InstanceTable(config.NamespaceCodeFirst, config.dbKey, config.dbFile, projectName);
            }

            if (config.IsCodeFirst && !string.IsNullOrEmpty(config.NamespaceCodeFirst) && !config.IsResource)
            {
                FastMap.InstanceProperties(config.NamespaceCodeFirst, config.dbFile);
                FastMap.InstanceTable(config.NamespaceCodeFirst, config.dbKey, config.dbFile);
            }

            if (!string.IsNullOrEmpty(config.NamespaceProperties) && config.IsResource)
            {
                FastMap.InstanceProperties(config.NamespaceProperties, config.dbFile, projectName);
            }

            if (!string.IsNullOrEmpty(config.NamespaceProperties) && !config.IsResource)
            {
                FastMap.InstanceProperties(config.NamespaceProperties, config.dbFile);
            }

            return(serviceCollection);
        }