/// <summary> /// Registers an instance of <see cref="ZipFilePacker"/> class as unpacker for DbInitializer. /// </summary> /// <param name="options">An instance of <see cref="IDbUtilsOptions"/>.</param> /// <param name="zipFilePath">The path to the file where the ZIP archive is stored. /// If null - `dataseed.zip` file will be used.</param> public static void UseZipPacker(this IDbUtilsOptions options, string zipFilePath = null) { if (string.IsNullOrEmpty(zipFilePath)) { zipFilePath = System.IO.Path.Combine(options.SeedDataFolder, "dataseed.zip"); } options.Unpacker = new ZipFilePacker(zipFilePath); }
/// <summary> /// Registers an instanse of <see cref="ResourceFileUnpacker"/> class as unpacker for DbInitializer /// </summary> /// <param name="options">An instance of <see cref="IDbUtilsOptions"/>.</param> /// <param name="assembly">The assembly with embedded resources</param> /// <param name="folderPath">The folder in resources.</param> public static void UseResourceFileUnpacker(this IDbUtilsOptions options, Assembly assembly, string folderPath = null) { if (string.IsNullOrEmpty(folderPath)) { folderPath = options.SeedDataFolder; } options.Unpacker = new ResourceFileUnpacker(assembly, folderPath, options.LoggerFactory); }
/// <summary> /// Registers an instance of <see cref="FileFolderPacker"/> class as unpacker for DbInitializer. /// </summary> /// <param name="options">An instance of <see cref="IDbUtilsOptions"/>.</param> /// <param name="folderPath">The path to the folder where the data files (the backup) are stored.</param> public static void UseFileFolderPacker(this IDbUtilsOptions options, string folderPath = null) { if (string.IsNullOrEmpty(folderPath)) { folderPath = options.SeedDataFolder; } options.Unpacker = new FileFolderPacker(folderPath); }
public static void UseDbContext(this IDbUtilsOptions options, DbContext dbContext, bool useMigrations) { options.DbWriter = new DbContextBridge(dbContext); if (useMigrations) { dbContext.Database.Migrate(); } }
/// <summary> /// Registers MySqlBridge as a DB writer in <see cref="IDbUtilsOptions"/> /// </summary> /// <param name="options">The options.</param> /// <param name="connection">The connection string.</param> public static void UseMySQL(this IDbUtilsOptions options, MySqlConnection connection) { options.DbWriter = new Korzh.DbUtils.MySql.MySqlBridge(connection, options.LoggerFactory); }
/// <summary> /// Registers PostgreBridge as a DB writer in <see cref="IDbUtilsOptions"/> /// </summary> /// <param name="options">The options.</param> /// <param name="connection">The connection.</param> public static void UsePostgreSql(this IDbUtilsOptions options, NpgsqlConnection connection) { options.DbWriter = new Korzh.DbUtils.PostgreSql.PostgreBridge(connection, options.LoggerFactory); }
/// <summary> /// Registers PostgreBridge as a DB writer in <see cref="IDbUtilsOptions"/> /// </summary> /// <param name="options">The options.</param> /// <param name="connectionString">The connection string.</param> public static void UsePostgreSql(this IDbUtilsOptions options, string connectionString) { options.DbWriter = new Korzh.DbUtils.PostgreSql.PostgreBridge(connectionString, options.LoggerFactory); }
/// <summary> /// Registers DbContextBridge as DB reader and DB writer in <see cref="IDbUtilsOptions"/>. /// SUPPORTS ONLY IN-MEMORY PROVIDER. /// </summary> /// <param name="options">Different options. An object that implements <see cref="IDbUtilsOptions"/> interface.</param> /// <param name="dbContext">An instance of <see cref="DbContext"/> (or inherited from it) class.</param> /// <exception cref="Korzh.DbUtils.EntityFrameworkCore.InMemory.DbContextBridgeException">This bridge supports only InMemory provider</exception> public static void UseInMemoryDatabase(this IDbUtilsOptions options, DbContext dbContext) { options.DbWriter = new Korzh.DbUtils.EntityFrameworkCore.InMemory.DbContextBridge(dbContext, options.LoggerFactory); }
/// <summary> /// Registers SqlServerBridge as a DB writer in <see cref="IDbUtilsOptions"/> /// </summary> /// <param name="options">The options.</param> /// <param name="connection">The connection.</param> public static void UseSqlServer(this IDbUtilsOptions options, SqlConnection connection) { options.DbWriter = new Korzh.DbUtils.SqlServer.SqlServerBridge(connection, options.LoggerFactory); }
/// <summary> /// Registers an instance of <see cref="XmlDatasetImporter"/> class as dataset importer for DbInitializer. /// </summary> /// <param name="options">An instance of <see cref="IDbUtilsOptions"/>.</param> public static void UseXmlImporter(this IDbUtilsOptions options) { options.DatasetImporter = new XmlDatasetImporter(options.LoggerFactory); }