This project is read-only.

Enum template & Foreign Keys

Sep 29, 2008 at 6:16 AM
The mapping a custom .net enum approach used in the installed code generation templates is interesting, however if each enum  is mapped to a column with the first row being the enum's value. How can you create the concpt of a Foreign Key to that value in the relational database?
Sep 29, 2008 at 12:53 PM
Correct - there is no way to have a foreign key constraint on a column with only the view this template generates. I created the "Enumeration with a SQL View" template to address the problem of using enumerations in TSQL code and to research use of CodeModel for code generation (more information here). It would be possible to extend this solution to generate both the view and CHECK constraint to enforce correctness of the column values. Generating a FOREIGN KEY would also be possible.