public static ConstraintInfo ForeignKey(string constraintName, ObjectName tableName, string[] columnNames,
ObjectName refTable, string[] refColumns)
{
if (tableName == null)
throw new ArgumentNullException("tableName");
if (refTable == null)
throw new ArgumentNullException("refTable");
if (columnNames == null || columnNames.Length == 0)
throw new ArgumentException("At least one column is required", "columnNames");
if (refColumns == null || refColumns.Length == 0)
throw new ArgumentException("At least one referenced column is required.", "refColumns");
if (columnNames.Length != refColumns.Length)
throw new ArgumentException("The number of columns in the constraint must match the number of columns referenced.");
var constraint = new ConstraintInfo(constraintName, ConstraintType.ForeignKey, tableName, columnNames);
constraint.ForeignTable = refTable;
constraint.ForeignColumnNames = refColumns;
return constraint;
}