Print Page | Close Window

Nullable Enum not supported ?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3897
Printed Date: 25-Oct-2025 at 12:46pm


Topic: Nullable Enum not supported ?
Posted By: kdev
Subject: Nullable Enum not supported ?
Date Posted: 17-Jan-2013 at 12:46am
Hi,

With EntityFramework, I can use in code first a Nullable Enum Property. The migration works well.
With Devforce this same nullable Enum property raise an exception during the build :

C:\Dev\packages\IdeaBlade.DevForce.Aop.7.0.3\tools\IdeaBlade.DevForce.Common.targets(61,5): error : An error occurred during metadata generation and a metadata file could not be created.  Error: The value cannot be null.

if I change to a no nullable property it works.

Is this a limitation of DF or a bug ? Is there a workaround ?



Replies:
Posted By: kimj
Date Posted: 17-Jan-2013 at 11:00am
DevForce does support nullable enum properties, so I don't know what might be going wrong.  Can you post a snippet showing your enum type and how the entity property is defined?


Posted By: kdev
Date Posted: 17-Jan-2013 at 11:08am
Here you go :


    [DataContract]
    public enum EtatEnum
    {
        [EnumMember]
        Waiting=1,
        [EnumMember]
        Validated = 2,
        [EnumMember]
        Sent = 3,
    }

    [DataContract(IsReference = true)]
    public class Purchase : PurchaseBase
    {
        ...

        [DataMember]
        public EtatEnum? Etat { get; set; }

        ...
    }



Posted By: kimj
Date Posted: 17-Jan-2013 at 11:20am
Hmm, this does look like a DevForce bug.  The nullable enums work from an EDMX-based model, but not in Code First.  I can't think of a workaround, but we'll get this fixed in the next release.


Posted By: kdev
Date Posted: 17-Jan-2013 at 11:45am
thank you, I can wait till the fix



Print Page | Close Window