Entity Framework Data Contract Serialization
Jul 19, 2014 There may be instances when using data transfer objects (DTO) is appropriate. For example, if you need to control the serialization details, such as which. Apr 25, 2010 Entity Framework POCO Classes Not Serializable. ADO.NET Entity Framework and LINQ to Entities section of the document to serialize.
You cannot use a buddy class and add DataContract or DataMember attributes. It's a bummer. Flipping Book Publisher Corporate America. If the easiest way is to just mark them with [DataContract] and [DataMember] attributes, just change the T4 template. There are two plug-ins that make it fairly easy to modify and both are free or have a free version: Alternatively when people talk about DTO's, the problem is copying the data from your POCO to a DTO. Since your DTO is probably almost EXACTLY the same as your POCO, you don't want to write a bunch of code to copy the values from one object to another. That's what automapper is for: It is an additional step, but then you can craft exactly what is going over the wire, including fixing collections, etc.
The best way for hooking up EF and WCF is by generating partial classes and interfaces which can be decorated with WCF attributes such as [DataContract], [DataMember]. If you are able to extract interfaces from entity classes, you will be able to expose the interfaces to more layers than just the Data Access and WCF. For instance, if you have 'internal class Person: IPerson', you can move 'public interface IPerson' into a class library project that contains only public interfaces. Download Free The Weathering Magazine Issue 01 Pdf Files. You can then set reference to this interface library from your WCF project, your WCF consumer (perhaps MVC) projects, your other class libraries and your unit test projects. To generate interfaces and apply attributes on generated classes and interfaces, you can download my open source project on Codeplex.