如何在poco模板中添加适用于复杂类型的wcf属性?

如何在poco模板中添加适用于复杂类型的wcf属性?,wcf,entity-framework-4,poco,Wcf,Entity Framework 4,Poco,我使用来自 首先,我的所有复杂类型都是使用wcf属性[DataContract][DataMember]生成的。当我重新生成时,我不知道为什么我所有的复杂类型都没有[DataContract][DataMember]。只有实体具有[DataContract][DataMember] [DataContract] <#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#&

我使用来自

首先,我的所有复杂类型都是使用wcf属性[DataContract][DataMember]生成的。当我重新生成时,我不知道为什么我所有的复杂类型都没有[DataContract][DataMember]。只有实体具有[DataContract][DataMember]

[DataContract]
<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#><#=code.StringBefore(" : ", code.Escape(entity.BaseType))#>
{
<#
    region.Begin("Primitive Properties");

    foreach (EdmProperty edmProperty in entity.Properties.Where(p => p.TypeUsage.EdmType is PrimitiveType && p.DeclaringType == entity))
    {
        bool isForeignKey = entity.NavigationProperties.Any(np=>np.GetDependentProperties().Contains(edmProperty));
        bool isDefaultValueDefinedInModel = (edmProperty.DefaultValue != null);
        bool generateAutomaticProperty = false;



#>

    [DataMember]
    <#=PropertyVirtualModifier(Accessibility.ForProperty(edmProperty))#> <#=code.Escape(edmProperty.TypeUsage)#> <#=code.Escape(edmProperty)#>
    {









//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Runtime.Serialization;
<#=String.Join(String.Empty, extraUsings.Select(u => "using " + u + ";" + Environment.NewLine).ToArray())#>
<#+
    fileManager.EndBlock();
}
[DataContract]
部分类
{
p、 TypeUsage.EdmType是基本类型(&p.DeclaringType==实体))
{
bool isForeignKey=entity.NavigationProperties.Any(np=>np.GetDependentProperties().Contains(edmProperty));
bool isDefaultValueDefinedModel=(edmProperty.DefaultValue!=null);
bool generateAutomaticProperty=false;
#>
[数据成员]
{
//------------------------------------------------------------------------------
// 
//此代码是从模板生成的。
//
//对此文件的更改可能会导致不正确的行为,如果
//重新生成代码。
// 
//------------------------------------------------------------------------------
使用制度;
使用系统集合;
使用System.Collections.Generic;
使用System.Collections.ObjectModel;
使用System.Collections.Specialized;
使用System.Runtime.Serialization;
使用“+u+”;“+Environment.NewLine).ToArray())#>

您尝试过以下扩展吗?
它适用于EF5和VS 2012,但EF 4.x也有相应的扩展


它允许生成已经用WCF属性修饰过的POCO,而无需自定义模板。

您可以发布代码吗?您是否可以返回到它工作的位置?我编辑了我的问题并发布了我的代码。我尝试返回到它工作的位置,但我无法。我甚至尝试删除t4模板并重新发布-这样做,但它不起作用。请编辑您的问题到一个合理的长度。只张贴相关的代码。