私には2つのエンティティがあります。1つは研究のコレクションを持つ患者です。
public class Patient
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<Study> Studies { get; set; }
}
public class Study
{
public Guid Id { get; set; }
public Guid PatientId { get; set; }
public string Name { get; set; }
}
このオブジェクトをデータベース「 Patients」と「Studies 」の2つのテーブルにマップしたいと思います。これを行うための構文はどうあるべきですか?「 EntityTypeConfiguration 」を使用しています。
class PatientEntityTypeConfiguration : EntityTypeConfiguration<Patient>
{
public PatientEntityTypeConfiguration()
{
this.HasKey(p => p.Id);
this.Property(p => p.Name)
.HasMaxLength(50)
.IsRequired();
//TODO: Map the studies!!!
this.ToTable("Patients");
}
}