Pergunta

Using SMO, I'm trying to determine the cardinality of ForeignKey relationships between tables in a SQL Server database. I could peruse each ForeignKeyColumn and look at each Column in the parent (and possibly also referenced) Tables, and look at the nullability of those columns as well as cross referencing with related Indexes to determine cardinality (multiplicity on each end such as 0..1, 1, *) as illustrated by the following entity-relationship diagram:

enter image description here

But, there should be a more straightforward way to do this. I don't see any relevant information in the ForeignKey Properties or ExtendedProperties. The only item I could find in the MSDN Library was an SfcCardinality enumeration, which states "Do not reference this member directly in your code. It supports the SQL Server infrastructure.".

Is there a straight forward way to get cardinality information via SMO?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top