public void ScaffoldInitialCreate_should_return_scaffolded_migration_when_db_initialized() { ResetDatabase(); var migrator = CreateMigrator <ShopContext_v1b>(); var initialCreate = new MigrationScaffolder(migrator.Configuration).Scaffold("InitialCreate"); migrator = CreateMigrator <ShopContext_v1b>(scaffoldedMigrations: initialCreate, contextKey: typeof(ShopContext_v1b).FullName); migrator.Update(); migrator = CreateMigrator <ShopContext_v1b>(contextKey: "NewOne"); var migrationsScaffolder = new MigrationScaffolder(migrator.Configuration); migrationsScaffolder.Namespace = "Foo"; var scaffoldedMigration = migrationsScaffolder.ScaffoldInitialCreate(); Assert.NotNull(scaffoldedMigration); Assert.NotSame(initialCreate, scaffoldedMigration); Assert.Equal(initialCreate.MigrationId, scaffoldedMigration.MigrationId); WhenNotSqlCe( () => Assert.Contains("INSERT [dbo].[MigrationsCustomers]([CustomerNumber],", initialCreate.UserCode)); }
public void ScaffoldInitialCreate_should_return_null_when_db_not_initialized() { ResetDatabase(); var migrator = CreateMigrator <ShopContext_v1>(); migrator.Update(); var migrationsScaffolder = new MigrationScaffolder(migrator.Configuration); migrationsScaffolder.Namespace = "Foo"; var scaffoldedMigration = migrationsScaffolder.ScaffoldInitialCreate(); Assert.Null(scaffoldedMigration); }
public void ScaffoldInitialCreate_should_return_scaffolded_migration_when_db_initialized_and_schema_specified() { ResetDatabase(); var migrator = CreateMigrator <ShopContext_v5>(); var initialCreate = new MigrationScaffolder(migrator.Configuration).Scaffold("InitialCreate"); migrator = CreateMigrator <ShopContext_v5>(scaffoldedMigrations: initialCreate, contextKey: typeof(ShopContext_v5).FullName); migrator.Update(); migrator = CreateMigrator <ShopContext_v5>(contextKey: "NewOne"); var migrationsScaffolder = new MigrationScaffolder(migrator.Configuration); migrationsScaffolder.Namespace = "Foo"; var scaffoldedMigration = migrationsScaffolder.ScaffoldInitialCreate(); Assert.NotNull(scaffoldedMigration); Assert.NotSame(initialCreate, scaffoldedMigration); Assert.Equal(initialCreate.MigrationId, scaffoldedMigration.MigrationId); }