Comments (18)

  1. Lukas says:

    Great to hear that you are actually working on that now. I cannot wait to throw out my manual enum parsing code. Checking of enums is not a concern for me. Illegal values should not appear when coding correctly and validating external input. They might occur in update scenarios – where you have to deal with them manually anyways and fix them to proper values. Disabling code generation is very important. HasFlags would also be quite helpful in some scenarios. Would get second prio from me, after disabling code generation.

  2. Dave W says:

    Same question as in pretty much every post on this blog, when are we going to actually see a release???  We have been waiting over 9months for the designer upgrades which has still yet to be released, and still no response despite several pleas;

    Don't need a date, just let us know whether all these desperately needed features might make it onto a release candidate / service pack , or are we just waiting for VS2012? In which the decision to use an alternative to EF has already been made for them

  3. Charlie H says:

    Great post. I think enum support would be a great addition to EF. Because I'd be replacing my independently written enum classes with EDM generated ones, disabling code generation is not as important to me as having a Checked attribute. Because my enums are almost always backed by a database table, I am always validating them. An optional Checked attribute would be very handy. Thanks for the post.

  4. @Dave W: the June 2011 CTP of EF is now available for download and includes support for enums, spatial types and TVFs among other improvements. More details about it here: blogs.msdn.com/…/announcing-the-microsoft-entity-framework-june-2011-ctp.aspx

  5. nayato says:

    Disabling code generation for enum and being able to hook up external enum (preferrable even from another assembly) is crucial for us. We use Entity Model for server-side logic and then we generate DTOs to talk to clients. It's quite natural to share enum between DTOs and entities. We're also sending expressions from the client side to constrain basic query defined on the server side (similar to WCF Data Services). Again, having single enum type shared between DTOs and entities would easy mapping of such expressions.

  6. benjaminjnr says:

    I personally like the work done so far.

    However, it's absolutely necessary to be able to constrain values in a field/property to the values of an Enum (using the Checked attribute as suggested).  

    Skipping code generation is also key for enums shared across libraries especially as there's no direct translation between enum types and the overhead of going to int an back again could just very well defeat the purpose.

    Bitwise support with HasFlags will be very useful and highly appreciated; right now I have a lot of || expressions to achieve the same effect.

  7. Dam says:

    Including enum support to ASP.NET Dynamic Data and WCF Data Service would also make a lot of sense, otherwise it very quickly becomes limited in term of real life scenario support. No API is an island, and that is especially true with EF which is rarely used alone in any significant development effort.

  8. bluerp says:

    yup i read the content . you should to describe it more.

    if you want more visitors for your site then youcan add your site

    into my social bookmark site.which is

    <a href="http://bluerayplus.com">Latest technology, ASP.net, SEO, Internet Marketing, SQL Server, AJAX, Silver Light, JQuery, Entity framework, PHP</a>

  9. Herbert says:

    There is no annotation attribute for Enumerations?

    For example: EF creates a lookup table for all public enums per default. This can be disabled by an <Ignore()> attribute.

  10. Herbert says:

    1. Using VB.NET I get "Error conversion from <enum item name> to 'integer' is not valid."

    2. In the context class, does the type x using an enum in modelbuilder.Entity(Of x) must have a DbSet(Of x) entry?

    3. Please publish a complete sample/how to guide of

    – a multi-layered object graph using enums and events

    – which is hosted in OData service as a singleton (!), supporting both XML/JSON

    – for which EF is used to create the DB

    – whose properties have different scopes for getter and setter

    Do I have to reconstruct event handlers  using AddHandler and delegates after reading from the DB?

    4. What is the best place to implement Open/Save on the DB? I suppose it is in the constructor and dispose of the WCF service class.

    I currently try to do this yet the info is scattered over hundreds of blogs and sometimes dating back to 2009. So I am not sure what is still valid, given the frequent CTPs of WCF/OData/REST, EF, Asnyc , ….

    thank you very much!  EF code first and OData and windows phone is a dream come true!

  11. Please include HasFlag support

  12. Springy says:

    "[..] to add enums support to EF, we are happy to say that we plan to do it in the next version after 4.1."

    Meanwhile there has been 4.2, 4.3 and 4.3.1 — all without enum support. You better not tell us your plans at all if plans just keep plans.

  13. Barry says:

    "Meanwhile there has been 4.2, 4.3 and 4.3.1 — all without enum support." … And now 4.4, again without enums.

  14. Microsoft programmer's Suck says:

    you morons. Ask Google for help. They are good at programming.

  15. Eric says:

    Hi, I have a doubt…EF 5 includes support for enums, but it seems to fail when it comes to a class having a property List<Enum>, it just dosen't take that list property when creating the DB…any tip on that??

    Thanks.

  16. Pissed off in St. Louis says:

    One more reason to stay away from Entity Framework.  Since starting on a project using Entity Framework I have lost countless hours coming up with 'work arounds' for crap like this.  My team was more efficient 10 years ago using DAO and dtos than they have been with this year using Entity Framework.

  17. Harry Vu says:

    HasFlag would be very useful. Thanks.

  18. Edward Brey says:

    HasFlag support would be useful if it came along with guidance for using flags enums in SQL Server and any related updates to DbMigration.CreateIndex. Specifically, can SQL Server efficiently index a bitfield so that arbitrary HasField queries are fast?