1
votes

I just started a project using EF. In VS 2012 the default template for edm model is now DBContext code generated template. I've searched a lot but could not find clarification anywhere on how to use WCF with DbContext. I need to build a WCF Service (not a WCF data service), so my questions are:

  1. Do I have to add WCF DataContract/DataMember attributes to serialize. How should I use DBContext with WCF (I am not using any DTOs). I will send POCOs generated from DBContext template across the wire.

  2. If I have to add attributes is there any way to modify the template to automaticaly add DataMember/DataContract attributes like they do in this post?

2

2 Answers

1
votes

DBContext is used for entity to entity mapping. And it is used to save the data in to the database. But if you want to pass out then you just create a prtail class and then Metadatatype and then you can customize that entity and then you can send it.

Please look the Metadatatype in entity framework.

0
votes

I managed to edit the template using the answer, as I am using Entity 4.x not EF 5. The only difference in template was mentioned by a user in comments in the same answer.