Welcome to the CodeSmith Community!

How to determine the foreign key tables and the cardinality

Support Forums

Feel free to ask any questions about CodeSmith here.

How to determine the foreign key tables and the cardinality

Answered (Verified) This question is answered

Dear all,

I'd like to know how to get the list of foreign key referenced tables and also the cardinality level (one-to-one, one-to-many, many-to-one,manay-to-many)?


  • Post Points: 35
Verified Answer
  • Hello,

    To get a list of foreign key referenced tables from a specific table you would use the TableSchema.ForeignKeys property. To figure out if a table is part of a relationship you would need to use logic like this code.google.com/.../Entity.cs . Please take a look at the GetParentAssociations() and GetChildAssociations() methods.

    I'd recommend using our SchemaHelper framework (latest version is included in the PLINQO EF and PLINQO nHibernate templates) if you are creating a business object framework. This framework uses interfaces and sits on top of SchemaHelper to provider you with a very nice model for creating framework templates (nTier/Business Object templates). The documentation is sparse as we haven't officially released it as a framework but all of our templates use it and are open sourced.

    Please let us know if you have any questions.


    -Blake Niemyjski

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

All Replies
Page 1 of 1 (4 items)