I am using EF 4.1 and POCO model (code only).
I have a Fiche entity which has Id as the primary key. And FicheCancellation entity, which has a Id which holds the Id of the Fiche that is cancelled and a CancellationFicheId which holds the Id of the generated cancellation Fiche's 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
...
}
now how do I configure navigations above, either with ForeignKey attributes or with ModelBuilder;
1- so that I have access to the cancellation entity.
2- and if the Fiche entity is a cancellation fiche, have a reference to the cancelled fiche.
精彩评论