Entity Framework should support mapping to Enum - by jods

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


109
0
Sign in
to vote
ID 365701 Comments
Status Closed Workarounds
Type Suggestion Repros 5
Opened 9/2/2008 9:04:01 AM
Access Restriction Public

Description

I think the title says it all. Linq to SQL supports this already, and it's useful.
Sign in to post a comment.
Posted by breakskater on 9/22/2011 at 7:58 AM
From the Code First approach, the EF Designer should generate a "look up table" with the name of the look up table being the name of the property, and the look up table should have at least Id and Name columns. Inverserly, from the Database First approach, an Enum should be generated from a look up table, perhaps only when adhering to a specific schema where the Enum names are derived from the Name column and the Enum values come from the Id column which in most cases will be Primary Keys and an Incremental Identity Integer field.
Posted by Daniel Smith on 7/4/2011 at 6:07 AM
The ADO.NET team released the June 2011 CTP recently, which now includes full support for enums in the model and the designer (wahoo!!!). See the following blog post:

http://blogs.msdn.com/b/adonet/archive/2011/06/30/announcing-the-microsoft-entity-framework-june-2011-ctp.aspx
Posted by RJMPhD on 2/10/2011 at 5:14 AM
I'm new to EF4. Is the workaround valid for designer-driven models?
Posted by NathanDavis on 2/8/2011 at 2:23 PM
EF really should support this feature. Very annoying when migrating from an ORM which does do enums (all the major ORMs I think) to EF4.
Posted by Daniel Smith on 10/4/2010 at 2:16 AM
Anyone who feels this is important, the data team also have an external voting site where they're trying to prioritize feature requests. It might be worth getting your votes in there too. Enum mapping is currently the #1 request:

http://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions
Posted by Sean Hederman on 9/8/2010 at 9:42 PM
I have officially just had my mind blown clean out the water. An ORM that doesn't support enums is an ORM still in development. Please change the status of Entity Framework from "Released" to "Still in development", and communicate to all Visual Studio owners that they should stop using EF until development is completed.
Posted by Drew Noakes on 8/16/2010 at 3:47 PM
+1 for this feature.

A somewhat hacky workaround is described here:

http://devtalk.dk/CommentView,guid,d5dccc2a-5723-49b4-97d1-bf759b7f592d.aspx
Posted by SaqibAliTipu on 6/28/2010 at 11:49 PM
Don't want to repeat myself

http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/82dcf8fa-3476-43bf-9520-87c36f891e30

This feature is forcing me to choose nhibernate for my next project. :@
Posted by Michael T. Bunney on 4/27/2010 at 4:48 PM
The cited workaround doesn't really solve the problem, because you can't use the pseudo-enum in LINQ queries. Entity Framework needs real enum support like that already in LINQ to SQL.
Posted by Nathan Zaugg on 2/11/2010 at 1:48 PM
I understand the arguments against, but we need to be able to choose!
Posted by PSvahn on 1/10/2010 at 1:30 PM
It's definitely a MUST HAVE for us. I would like to see the same support as in LINQ to SQL, where enum can also be mapped to strings or ints.
Posted by Daniel Smith on 9/8/2009 at 2:02 AM
It's really disappointing that enum support likely isn't going to make it into the VS2010/.NET 4.0. It's one of the last remaining adoption barriers for me, so it's a bit of a let down that we'll likely have to wait a couple of years after the 2010 release before this is addressed.

In fact, enum support is such a key scenario, I'd be more than happy for the entire VS2010 product release to be delayed in order to fit this feature in.
Posted by Shadow Chaser on 12/22/2008 at 2:58 PM
I'd really like to see this added.

In our database design, we have a number of "type" tables that map directly to enumerations in the business logic layer. The tables exist purely for database integrity - ensuring the values are within a valid range.

With v1.0 of the entity framework, I can't model this pattern:
* The entity framework forces me to use a "navigation property" to the type table due to the foreign key
* The entity framework does not allow me to have a "shortcut" property (even if settable = private) letting me set the type directly at the same time as having a navigation property
* The entity framework does not support enumerations.

At this point, I'm SOL. The entity framework has completely failed me, and I'm forced to abandon it.
Posted by Microsoft on 9/25/2008 at 9:49 AM
Thank you for reporting this issue. We will look at addressing this in the next release.

Entity Designer Team