Wednesday, May 7, 2014

Smo: How to get the table a foreign key refers to

foreach (ForeignKey key in currentTable.ForeignKeys)
{
    foreach (ForeignKeyColumn column in key.Columns)
    {
        Console.WriteLine("Column: {0} is a foreign key to Table: {1}", column.Name, key.ReferencedTable);
    }
}

No comments:

Post a Comment