私は抽象クラスを持っています
public abstract class Document
{
public int DocumentID {get; set;}
}
および派生クラス
public class DoctorDocument : Document{
public string DoctorName {get;set;}
}
Fluent Auto Mappingを使用している
ので、Documentのテーブルを作成する必要はありませんが、DocumentIDを主キーとして取得するには各派生クラスが必要です。
mappings.IgnoreBase<Document>();
mappings.AddEntityAssembly(typeof(DoctorDocument).Assembly);
mappings.Setup(c=>c.FindIdentity = type.Name == type.DeclaringType.Name + "ID";);
しかし、それでもIDが見つからず、DoctorDocumentにIDがないことを通知します。しかし、私が次のオーバーライドを行ったとき、それは機能しました:
public class DoctorDocumentMap: IAutoMappingOverride<DoctorDocument>
{
public void Override(AutoMapping<DoctorDocument> mapping)
{
mapping.Id(x => x.Id, "DocumentID").GeneratedBy.Identity();
}
}
すべてのエンティティに対してそれを行うように自動マッピングに指示するにはどうすればよいですか?特にGeneratedBy.Identity();