Entity Framework 4 – “Almost” POCO

This is a short rant..

I have been very impressed with EF4 so far, but I’ve now found out that EF4 will NOT support enums.
I find this is very strange, I can’t see how Microsoft can claim POCO support and not support one of the most common code constructs.

More info here:

http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/7659feab-d348-4367-b2cd-0456b20262fe

Someone might claim that you can create a private property containing the mapped integer value and then make a public property exposing the enum.
But this comes with two major drawbacks:

1) You can’t create Linq queries that are executed at DB level if you use unmapped properties.
The Linq query would have to use the integer property, and thus loosing it’s semantics.

2) That is not POCO, that is mapper requirements leaking all over the place.

2 thoughts on “Entity Framework 4 – “Almost” POCO”

  1. @Nikola, yes i have seen it and think it is a _horrible_ approach.

    This is by no means at all POCO, and nor does it support linq queries against the enum property.

    The entire idea behind POCO is to let you design your model w/o caring about persistence concerns.

    Since this forces you to design a certain way, this kills the value of POCO.

    As for now I think that using constants in a static class is the best replacement for enums in EF4 since this supports Linq queries and will be very easy to port once we get real enum support.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s