public async Task MigrateGroup1Preview()
    {
        var model = DbModelFactory.GenerateModel(new Migration1().Types);

        model.OutputTableDatas.PrintStringTable("Tables in Topological Order");

        //Also, let's do a spot check on the Quantity columns MyDecimalSqlTypeAttribute data type.
        var orderLine2Table = model.OutputTableDatas.Single(z => z.TableName.Table == nameof(OrderLine2));
        var quantityColumn  =
            orderLine2Table.ColumnCreationData.Single(z => z.ColumnDataName.Name == nameof(OrderLine2.Quantity));
        var myDecimalSqlTypeAttribute = quantityColumn.SqlTypeAttribute as MyDecimalSqlTypeAttribute;

        myDecimalSqlTypeAttribute.Precision.Should().Be(38);
        myDecimalSqlTypeAttribute.Scale.Should().Be(12);

        //And now let's print out the migration.
        var dbManipulator = new DbManipulator(new SqlServerDbAdapter(null),
                                              typeof(RunMigrationsTest).Assembly,
                                              new[] { "Group1" });

        dbManipulator.ShowSql         = true;
        dbManipulator.ShowElapsedTime = false;
        dbManipulator.PreviewOnly     = true;
        await dbManipulator.UpdateDatabase();
    }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            var userId = userManager.GetUserId(User);

            var checks = DbManipulator.GetUserChecks(context, userId);

            return(View(checks));
        }
    public async Task MigrateGroup1AgainstActualServer()
    {
        var dbManipulator = new DbManipulator(new SqlServerDbAdapter(_scp),
                                              typeof(RunMigrationsTest).Assembly,
                                              new[] { "Group1" });

        dbManipulator.ShowSql = true;
        await dbManipulator.CreateAndUpdateDatabase();
    }
    public async Task MigrateGroup2()
    {
        Func <Task> failCreatingDatabase = new Func <Task>(async() =>
        {
            var dbManipulator = new DbManipulator(new SqlServerDbAdapter(_scp),
                                                  typeof(RunMigrationsTest).Assembly,
                                                  new[] { "Group1" });
            await dbManipulator.CreateAndUpdateDatabase();
        });

        await failCreatingDatabase.Should()
        .ThrowAsync <Exception>(
            $"This fails because FluentMigrator doesn't sequence operations in appropriate order. {nameof(DbModelFactory)} can help topologically sort create statements to prevent this.");
    }