This project is read-only.

Enumeration to Entity compile error

Jan 26, 2013 at 12:58 AM


I created a "Gender" Entity and set its Typed Entity to EnumOnly, entered two static data rows (male and female). Then I tried to create a dropdown list with these two values, but I didn't know how to populate it using the enumeration (actually is there a way? how can I access the "Male" and "Female" strings and their corresponding enumeration values?)

So I decided to set the Typed Entity to Database Table, so that I get the corresponding entity named Gender and its two fields (id and name) to populate the dropdown. But then, I couldn't compile, I was getting an error in the Gender.Generated.cs about the "Description" attribute of the two enumeration fields. The problem disappeared only when I set the Typed Entity to "None".

So what is the meaning of the "Database Table" ? My rough understanding is that the "EnumOnly" is present only in my code, where the enumeration is populated by static data. The "None" is a normal entity present in the database. So what is the third "Database Table" status?

Many thanks,


Feb 5, 2013 at 12:40 PM
Database table does mean that there is a table created with static data inserted. This ensure referential integrity. An enumeration is created to match the static data and you can use it in code instead of magic numbers. The Enum only option creates just the Enum with no database backing table. None is just a table. It is not a type table. If you have a compile issue, please send your model to as I would like to determine if there is an issue.
Feb 6, 2013 at 11:30 AM
Thanks for your reply.
So the actual question is wtah is the difference between a "table" and a "type table"?

I will send the model to the mail you requested, with a reference to this discussions thread.
Let me here describe the procedure to reproduce the problem:
  1. Set the entity "Gender" typed entity property to "None"
  2. Right click on the model and generate
  3. Rebuild my solution, workd fine
  4. Set the entity "Gender" typed entity property to "Database Table", the entity's colour in the designer changes to light blue.
  5. Repeat 2
  6. Repeat 3, get compile errors.
Best regards,
Feb 20, 2013 at 1:09 PM
I think we fixed this offline. However for an explanation of type tables here it is. A type table is a database table that has a backing enumeration in code. So you define an ID/Name table and the ID numeric value is the enum's numeric value and the Name field is the text definition. you must define one or more static data values by right clicking the model entity and adding static data. These are the values for the enumeration. Also in code the entity object is read-only. You cannot add or remove these items from the database and cannot edit the existing value. They all have private setters for fields. Also all related tables have an enumeration reference to the type table.

So Person table is linked to Gender table. The Person object in code has a GenderTypeValue property that is an enum so instead of this.

person.GenderId = 2;

You have code like this.

Person.GenderTypeValue = GenderTypeConstants.Male;

It makes your code much more readable.