Since EF4 is lacking enum support, I've been trying to implement the workaround listed at:
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'm using the POCO generator for EF4 (which the article does NOT use) and I keep getting the following runtime error:
Mapping and metadata information could not be found for EntityType...
Presumably this is because CreateObjectSet doesn't understand the wrapper class.
Has anyone been able to find a suitable solution for supporting enums in EF4 with generated POCOs?
Thanks.
Yes, enum type properties are not supported by EF4 (or CTP5); of course we need them, and I've heard that they will be implemented 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
.
It is ugly but it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With