entity framework 5 - Map a field to an enum in EntityFramework 5 Code First -


In this way, I have a class, as follows:

  public class Message {public anonym message type {text = 0, audio = 1, image = 2} public at UID {received; Set; } Public message type type {get; Set; } Public string text {get; Set; }}   

As you can see, the type field is an enum, to match the data of this class, my mapping is defined as:

  Public class MessagesMap: EntityTypeConfiguration & lt; Message & gt; {Public Message Map () {// Primary key is this. Husky (t = & gt; TUID); // Properties This Property (T = & gt; T. Test). Haemax Lang (1000); // Table & amp; This column mapping. Toubles ("wc_messages"); this. Property (T = & gt; T.U.D.). Column name ("UID"); this. Property (T = & gt; T. type) .HasColumnName ("Type"); this. Property (T = & gt; T. text). Column name ("text"); }}   

But when I run the code, I get the following error:

There is no declared property of type 'property' type 'message' . Verify that the property has not been explicitly excluded from the model by using the ignored method or NotMappedAttribute data annotation. Make sure this is a valid primitive asset.

I think I'm getting an error because the type properties are not primitive but rather an enum. If I understand correctly, however, EF5 supports enums (and I'm targeting .NET 4.5 framework). So I think there is something missing in my mapping, which tells me how to convert enum, but I am getting damaged as what is it, if I change the field back to an integer then all this Works fine, this only occurs when the field type of anom me get an error.

What am I missing? thank you in advanced.

So it turns out that I'm just stupid and my enum block was declared inside POCO The class and totally failed to notice it. I realized that it was thanks to a ninja comment from @overmachin (which later disappeared) and due to the announcement of going out of my class due to all the work properly, everything got better. Thanks, they go to wherever they go, and the lesson learns to be more aware sigh

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -