【发布时间】:2013-01-03 07:53:33
【问题描述】:
我有 2 个实体,一个有一系列研究的患者。
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");
}
}
【问题讨论】:
标签: .net entity-framework domain-driven-design entity-framework-5 ddd-repositories