Mam typu złożonego dla pól KontroliEF-Code First Property nawigacja klucz obcy w typu złożonego
Mój typ złożony:
[ComplexType]
public class AuditData {
[Column("CreatorUserId")]
public int? CreatorUserId { get; set; }
public DateTime? CreationTime { get; set; }
[Column("ModifierUserId")]
public int? ModifierUserId { get; set; }
public DateTime? ModificationTime { get; set; }
}
Moja baza Entity (wszystkie inne inherti ten) ma właściwość AuditData:
public abstract class Entity : IEntity, IAuditedEntity, INotifiedDbContextBeforeSave
{
// Summary:
// Unique identifier for this entity.
public int Id { get; set; }
public bool IsActive { get; set; }
public int Old_Id { get; set; }
public string Old_TableName { get; set; }
[Timestamp]
public byte[] RowVersion { get; set; }
public AuditData AuditData { get; set; }
// can this 2 lines below work as navigation property with foreign key in complex type
public virtual User CreatorUser { get; set; }
public virtual User ModifierUser { get; set; }
//... other fields
}
Mam 2 właściwości nawigacji CreatorUser i ModifierUser. wiem, nie można mieć właściwości nawigacyjnego w complexType ale może moja własność nawigacja na jednostkę być odwzorowywane z klucza obcego w complexType
coś takiego:
[ForeignKey("CreatorUserId")] // --> should point to AuditData.CreatorUserId
public virtual User CreatorUser { get; set; }
poniewaz CreatorUserId będzie nieruchomość w każdym podmiocie ale EF nie jest świadomy tego. Mybe czy istnieje płynne API?