Enum wrappers and Entity Model
I am creating an Entity model applying the Model first approach. I want that some of the entity classes have properties of the EnumWrapper type (http://blogs.msdn.com/b/alexj/archive/2009/06/05/tip-23-how-to-fake-enums-in-ef-4.aspx). What should I do to achieve this? Is adding plain int-type properties will be the correct approach? And after generating a database, the entity objects will be customized som开发者_如何学Cehow by replacing int properties on appropriate enum wrappers.
No your entity must contain Complex type created for concrete enum wrapper. Each enum wrapper will contain single field of int type (you should make unique name of the field for each wrapper).
Described approach in the article works only if you create POCO classes manually because you must modify enum wrappers directly. You can also probably make it work if you modify T4 template.
It can't be used with default entity object code generated by custom tool (edmx code behind file) because there is no way to modify generated complex types (they will be overwritten each time you touch EDMX).
精彩评论