1

I'm planning on using EF in a WCF Service. The database that will be used already exists.

I was wondering if I need to map the retreived entities to a datacontract, or can I use them directly?

And on a more general base: are there any pitfalls I should beware of?

Koen
  • 2,501
  • 1
  • 32
  • 43

2 Answers2

1

If EF generates POCO classes for your existing DB, then WCF should be able to serialize the classes by just using their public properties, even without them being marked as a [DataContract]. However if they are non-POCO tracking objects, then you will probably have to translate them to a different type for WCF to serialize it.

But there are so many versions and configurations and ways to use WCF and EF, that it is hard to answer this with any certainty.

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
  • Then I guess there's only one thing to do: Trial and error. :-) When googling around I found a lot of Code First blogs/examples but no Database First. I will start to code and see if/where I get stuck... – Koen Mar 31 '12 at 17:59
0

You might consider using Entity Framework Provider (WCF Data Services)

Ricibob
  • 7,505
  • 5
  • 46
  • 65
paramosh
  • 2,258
  • 1
  • 15
  • 23