I would like some help adding in a POCO .tt Entity Framework template Attributes to support WCF serialization and if its possible how to add namespace usings to each entity.
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to open your
model1.ttfile (or whatever it’s called in your project), and add a few things.Locate these lines of code (line 34, in my case):
Just before this line here:
you need to add the
[DataContract]attribute:to your template.
Next, locate this line of code:
Before that line, add the
[DataMember]attribute to your template:This will add those attributes for all entities and all properties – that might not be what you really want, but it’s a start.
Also: to finish off, you probably want to have a look at the
WriteHeaderfunction in your T4 template, and add theusing System.Runtime.Serialization;statement to your list of usings: