/// <summary>
        /// Initializes a new instance of the <see cref="TestData"/> class.
        /// </summary>
        /// <param name="db">The database context.</param>
        /// <param name="configuration">The optional configuration to use.</param>t
        private TestData(Database db, TestDataConfiguration configuration)
        {
            _db            = db;
            _configuration = configuration;

            // Default to looking in the Data folder of the calling assembly
            if (string.IsNullOrEmpty(_configuration.DataFolder))
            {
                var assemblyFolder = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
                _configuration.DataFolder = Path.Combine(assemblyFolder, "Data");
            }
        }
        /// <summary>
        /// Creates data in the supplied database context.
        /// </summary>
        /// <param name="db">The database context.</param>
        /// <param name="dataFolder">The data folder.</param>
        public static void Import(Database db, TestDataConfiguration configuration = null)
        {
            lock (_lock)
            {
                if (_haveCreated)
                {
                    // Throw an exception if there has previously been an error so that it shows up against all the user's tests
                    if (_haveErrored)
                    {
                        throw new InvalidOperationException(_errorMessage);
                    }
                }
                else
                {
                    _haveCreated = true;
                    try
                    {
                        var config = configuration ?? new TestDataConfiguration();

                        var creator = new TestData(db, config);

                        config.OnBeforeImport(db);

                        creator.LoadDataFiles();
                        creator.CreateDatabase();
                        creator.CreateData();

                        config.OnAfterImport(db);
                    }
                    catch (Exception ex)
                    {
                        _haveErrored  = true;
                        _errorMessage = ex.ToString();
                        throw;
                    }
                }
            }
        }