关系映射问题

时间:2011-06-06 13:56:09

标签: entity-framework-4

我使用的是EF 4.1和POCO模型(仅限代码)。

我有一个以Id为主键的Fiche实体。 和FicheCancellation实体,其Id保存被取消的Fiche的Id,而CancellationFicheId保存生成的取消Fiche的Id的Id

    class Fiche {
       public Guid Id {get; set;}
       ...
       public virtual Fiche CancelledFiche {get; set;}
       public virtual Fiche CancellationFiche {get; set;}
       public virtual FicheCancellation Cancellation {get; set;}
    }
    class FicheCancellation {
        // cancelled FicheId
        public Guid CancelledFicheId {get; set;}
        //generated cancellation ficheId
        public Guid CancellationFicheId {get; set;}

        public virtual Fiche CancelledFiche {get; set;}
        public virtual Fiche CancellationFiche {get; set;}
....
some other fields about the operation
...

    }

现在如何使用ForeignKey属性或使​​用ModelBuilder配置上面的导航;

1-以便我可以访问取消实体。

2-如果Fiche实体是取消抵消,请参考取消的fiche。

0 个答案:

没有答案
相关问题