Exemple #1
0
        public WFDatabaseFixture(IConfiguration config)
        {
            _config = config;
            var connectionString = _config.GetSection("MySQL")["Connection"].ToString();

            Db = new WFDbContext(connectionString);
        }
Exemple #2
0
        public WFDatabaseFixture(IConfiguration config)
        {
            _config = config;
            //docker compose获取配置信息
            string MYSQL_DB = _config.GetSection("MYSQL_DB").Value;

            if (string.IsNullOrEmpty(MYSQL_DB))
            {
                var section = _config.GetSection("MySQL");
                Db = new WFDbContext(section["Connection"].ToString());
            }
            else
            {
                string MYSQL_USER       = _config.GetSection("MYSQL_USER").Value;
                string MYSQL_PASS       = _config.GetSection("MYSQL_PASS").Value;
                string MYSQL_HOST       = _config.GetSection("MYSQL_HOST").Value;
                string connectionString = $"Database={MYSQL_DB};Data Source={MYSQL_HOST};User Id={MYSQL_USER};Password={MYSQL_PASS}";
                Db = new WFDbContext(connectionString);
            }
        }