public DbMigrator CreateMigrator <TContext>( DbMigration migration, IEnumerable <Tuple <string, MigrationSqlGenerator> > sqlGenerators = null, bool automaticDataLossEnabled = false) where TContext : DbContext { using (var context = CreateContext <TContext>()) { var operations = migration.GetOperations(); var generatedMigration = CodeGenerator .Generate( GenerateUniqueMigrationName(migration.GetType().Name), operations, Convert.ToBase64String(CompressModel(GetModel(context))), Convert.ToBase64String(CompressModel(GetModel(context))), "System.Data.Entity.Migrations", migration.GetType().Name); return(new DbMigrator(CreateMigrationsConfiguration <TContext>( scaffoldedMigrations: generatedMigration, sqlGenerators: sqlGenerators, automaticDataLossEnabled: automaticDataLossEnabled))); } }
public DbMigrator CreateMigrator <TContext>(DbMigration migration) where TContext : DbContext { var modelCompressor = new ModelCompressor(); var generatedMigration = CodeGenerator .Generate( UtcNowGenerator.UtcNowAsMigrationIdTimestamp() + "_" + migration.GetType().Name, migration.GetOperations(), Convert.ToBase64String(modelCompressor.Compress(CreateContext <TContext>().GetModel())), Convert.ToBase64String(modelCompressor.Compress(CreateContext <TContext>().GetModel())), "System.Data.Entity.Migrations", migration.GetType().Name); return(new DbMigrator(CreateMigrationsConfiguration <TContext>(scaffoldedMigrations: generatedMigration))); }
public DbMigrator CreateMigrator <TContext>(DbMigration migration) where TContext : DbContext { using (var context = CreateContext <TContext>()) { var generatedMigration = CodeGenerator .Generate( GenerateUniqueMigrationName(migration.GetType().Name), migration.GetOperations(), Convert.ToBase64String(CompressModel(GetModel(context))), Convert.ToBase64String(CompressModel(GetModel(context))), "System.Data.Entity.Migrations", migration.GetType().Name); return(new DbMigrator(CreateMigrationsConfiguration <TContext>(scaffoldedMigrations: generatedMigration))); } }
private static string GetDefaultSchema(DbMigration migration) { try { string str = new ResourceManager(migration.GetType()).GetString("DefaultSchema"); return(!string.IsNullOrWhiteSpace(str) ? str : "dbo"); } catch (MissingManifestResourceException ex) { return("dbo"); } }
private static string GetDefaultSchema(DbMigration migration) { DebugCheck.NotNull(migration); try { var defaultSchema = new ResourceManager(migration.GetType()).GetString(DefaultSchemaResourceKey); return(!string.IsNullOrWhiteSpace(defaultSchema) ? defaultSchema : EdmModelExtensions.DefaultSchema); } catch (MissingManifestResourceException) { // Upgrade scenario, no default schema resource found return(EdmModelExtensions.DefaultSchema); } }