public void AddForeignKeyConstraint()
{
var tableName = ObjectName.Parse("APP.test_table2");
var constraint = new SqlTableConstraint("FK_1", ConstraintType.ForeignKey, new[] { "person_id" }) {
ReferenceTable = "APP.test_table",
ReferenceColumns = new[] { "id" }
};
AdminQuery.AddConstraint(tableName, constraint);
var fkeys = AdminQuery.Session.Access().QueryTableForeignKeys(tableName);
Assert.IsNotNull(fkeys);
Assert.IsNotEmpty(fkeys);
var fkey = fkeys.FirstOrDefault(x => x.ConstraintName == "FK_1");
Assert.IsNotNull(fkey);
Assert.IsNotNull(fkey.ForeignTable);
Assert.AreEqual("APP.test_table", fkey.ForeignTable.FullName);
Assert.IsNotNull(fkey.ForeignColumnNames);
Assert.IsNotEmpty(fkey.ForeignColumnNames);
}