Adding [DataMember] [DataContract] attributes in Entity Framework POCO Template

后端 未结 2 1851
闹比i
闹比i 2020-12-03 05:28

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.

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 06:08

    In EF6.1 you need to edit the model1.tt and add tag between UsingDirectives and EntityClassOpening:

    <#=codeStringGenerator.UsingDirectives(inHeader: false)#>
    //MY TAG:
    [Serializable]
    <#=codeStringGenerator.EntityClassOpening(entity)#>
    

提交回复
热议问题