Transfers in generated objects EF4 POCO

Since EF4 lacks enum support, I am trying to implement a workaround specified in:

http://blogs.msdn.com/b/alexj/archive/2009/06/05/tip-23-how-to-fake-enums-in-ef-4.aspx?PageIndex=1&CommentPosted=true#comments

However, I use the POCO generator for EF4 (which the article DOES NOT use), and I continue to receive the following runtime error:

Display and metadata information not found for EntityType ...

Presumably this is because CreateObjectSet does not understand the wrapper class.

Has anyone been able to find a suitable solution to support transfers in EF4 with generated POCOs?

Thanks.

+7
source share
1 answer

Yes, enumeration type properties are not supported by EF4 (or CTP5); Of course, we need them, and I heard that they will be implemented in the next release.

Here is a workaround:

public enum FieldDataType { Image, RawText, Ajax } public class DefinitionDynamicField { public int FieldType { get; set; } [NotMapped] public FieldDataType FieldTypeObserver { get { return (FieldDataType)FieldType; } set { return FieldType = (int)value; } } } 

We use FieldTypeObserver instead of FieldType .

This is ugly, but it works.

+7
source

All Articles