0

TPH マッピングに問題があります。クラスは次のとおりです。

抽象サービス (基底クラス)

[Table("Services")]
public abstract class AbstractService : IAuditedObject
{
    public int Id { get; set; }

    [DisplayName("Receiver Site")]
    public int? TargetSiteId { get; set; }
    [DisplayName("Receiver Site")]
    public virtual Site TargetSite { get; set; }

    [DisplayName("Start Date")]
    public PartialDate StartDate { get; set; }
    [DisplayName("End Date")]
    public PartialDate EndDate { get; set; }

    [DisplayName("Study")]
    public int? StudyId { get; set; }
    [DisplayName("Study")]
    public virtual Study Study { get; set; }
}

具体的なサービス

public class AssociatedStaffService : AbstractService
{
    [DisplayName("Person")]
    [Required]
    public int? SourcePersonId { get; set; }
    [DisplayName("Person")]
    public virtual Person SourcePerson { get; set; }

    [DisplayName("Service")]
    [Required]
    public int? RoleId { get; set; }
    [DisplayName("Service")]
    public virtual AssociatedStaffServiceCLI Role { get; set; }

    [DisplayName("Department")]
    public string Department { get; set; }

    public bool IsActive()
    {
        return this.SourcePerson != null && this.TargetSite != null && this.SourcePerson.IsActive() && this.TargetSite.IsActive() && this.Study != null && (this.EndDate == null || this.EndDate.Date == null || this.EndDate.Date > DateTime.Now);
    }
}

public class EthicCommitteeService : AbstractService
{
    [DisplayName("Site")]
    [Required]
    public int? SourceSiteId { get; set; }
    [DisplayName("Site")]
    public virtual Site SourceSite { get; set; }

    [DisplayName("Central")]
    public bool? IsCentral { get; set; }

    public bool IsActive()
    {
        return this.Study != null && this.TargetSite != null && this.SourceSite != null && this.TargetSite.IsActive() && this.SourceSite.IsActive() && (this.EndDate == null || this.EndDate.Date == null || this.EndDate.Date > DateTime.Now);
    }
}

public class ParticipatingService : AbstractService
{
    public const string AUTHORIZATION_DATE = "AuthorizationDate";
    public const string IS_NATIONAL_COORDINATOR = "IsNationalCoordinator";

    [DisplayName("Person")]
    [Required]
    public int? SourcePersonId { get; set; }
    [DisplayName("Person")]
    public virtual Person SourcePerson { get; set; }

    [DisplayName("Service")]
    [Required]
    public int? RoleId { get; set; }
    [DisplayName("Service")]
    public virtual ParticipatingServiceCLI Role { get; set; }

    [DisplayName("Department")]
    public string Department { get; set; }

    public int? RegInvestigatorFormId { get; set; }
    public PartialDate AuthorizationDate { get; set; }
    public bool? IsNationalCoordinator { get; set; }

    public bool IsActive()
    {
        return this.SourcePerson != null && this.TargetSite != null && this.SourcePerson.IsActive() && this.TargetSite.IsActive() && this.Study != null && (this.EndDate == null || this.EndDate.Date == null || this.EndDate.Date > DateTime.Now);
    }
}

public class ExternalService : AbstractService
{
    [DisplayName("Person")]
    [Required]
    public int? SourcePersonId { get; set; }
    [DisplayName("Person")]
    public virtual Person SourcePerson { get; set; }

    [DisplayName("Service")]
    [Required]
    public int RoleId { get; set; }
    [DisplayName("Service")]
    public virtual ExternalServiceCLI Role { get; set; }

    [DisplayName("Department")]
    public string Department { get; set; }

    public bool IsActive()
    {
        return this.SourcePerson != null && this.TargetSite != null && this.SourcePerson.IsActive() && this.TargetSite.IsActive() && this.Study != null && (this.EndDate == null || this.EndDate.Date == null || this.EndDate.Date > DateTime.Now);
    }
}

public class StudyTeamService : AbstractService
{
    [DisplayName("Person")]
    [Required]
    public int? SourcePersonId { get; set; }
    [DisplayName("Person")]
    public virtual Person SourcePerson { get; set; }

    [DisplayName("Service")]
    [Required]
    public int? RoleId { get; set; }
    [DisplayName("Service")]
    public virtual StudyTeamServiceCLI Role { get; set; }

    [DisplayName("Department")]
    public string Department { get; set; }

    public bool IsActive()
    {
        return this.SourcePerson != null && this.TargetSite != null && this.SourcePerson.IsActive() && this.TargetSite.IsActive() && this.Study != null && (this.EndDate == null || this.EndDate.Date == null || this.EndDate.Date > DateTime.Now);
    }
}

私は常に次のエラーが発生します:

--- エラー: モデルの生成中に 1 つ以上の検証エラーが検出されました:

    System.Data.Edm.EdmProperty: Name: Each property name in a type must be unique. Property name 'StartDate' is already defined.
    System.Data.Edm.EdmProperty: Name: Each property name in a type must be unique. Property name 'EndDate' is already defined.  ---

そして、ここにスタックトレースがあります:

未処理の例外: System.Data.Entity.ModelConfiguration.ModelValidationException: モデルの生成中に 1 つ以上の検証エラーが検出されました:

    System.Data.Edm.EdmProperty: Name: Each property name in a type must be unique. Property name 'StartDate' is already defined.
    System.Data.Edm.EdmProperty: Name: Each property name in a type must be unique. Property name 'EndDate' is already defined.

Prisma.Loader.PrismaLoader.Init() の C:\Projects_PrismaLoader\Prisma.Load er\PrismaLoader.cs:line 95 at Prisma.Loader.PrismaLoader.Load(Boolean quick) in C:\Projects_PrismaLoader\Prisma.Loader\ PrismaLoader.cs:C:\Projects_PrismaLoader\Pri sma.Loader\Program.cs:行 113 の Prisma.Loader.Program.Main(String[] args) の行 32

この場合、スタック トレースはあまり役に立ちません (どうやら...)

誰が私がどこで間違いを犯したのか知っていますか? 一日中探してました…

4

2 に答える 2

0

StartDate と EndDate を仮想にする必要があると思いますか? Edm は機能をオーバーライドしようとしていますが、封印されているためオーバーライドできないため、IL で複製していますか?

于 2012-04-11T13:24:41.947 に答える
0

解決済み

問題は PartialDate クラスだったようです。[ComplexType] 注釈を付ける必要があります。

于 2012-04-13T06:31:54.560 に答える