Take the 2-minute tour ×

I was wondering how people are handling the lack of Enum support in Entity Framework when dealing with WCF services?

Common practice seems to be to declare getter & setter in the entity property to private and then create a partial class for the entity and declare the enum property in there.

This is all fine and dandy but poses an issue for WCF services. I need the Enum definition on the client side and want this to happen through the automatic proxy generation. To do so I have to add the DataMember attribute to the Enum Property in the shared class, so it will be included in the serialization process.
However, when I call a the WCF method now, it serializes both, the (int) and (Enum) property, thus carrying redundant data and increasing message size. What's the best way to deal with this and how are other people handling this scenario?



share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

I agree that EF objects should not be sent over WCF. By doing so, you are exposing too much implementation detail of what is behind the WCF service.

To limit the amount of code you need to write to facilitate the transformation from EF objects to DTOs/POCOs exposed by the WCF service, take a look at Automapper.

share|improve this answer
ty, +1 for the Automapper suggestion –  TJF Nov 24 '09 at 16:22
add comment

We do not send EF objects over WCF.

We map the objects to DTO's (Data Transfer Objects) and send them over WCF.

This will change with EF 4, where there is support for POCO (Plain Old CLR Objects)

share|improve this answer
Thanks, this makes perfect sense. Would you continue to use DTO's with EF 4 or would you pursue the EF 4 POCO implementation? I'm just looking at some articles about it to see if it will work well –  TJF Nov 24 '09 at 16:13
add comment

So EF 4 don't support Enum...Let's find others solutions.

Let's say you have a OrderStatus enum, if you want to follow strict db design rules, you should create a OrderStatus table. You can then add info to your "enum" table such as:

  • Value (int or string)
  • Localizable description

Then you will create a foreign key in your table referencing it. This is one solution.

Now the other one is to replace the status id with a complex type:


share|improve this answer
add comment

Your Answer


