给定这个类:
public class Basket
{
public int Id { get; set; }
private string SomeProperty { get; set; }
private Address Address { get; set; }
public class BasketMapper : EntityTypeConfiguration<Basket>
{
public BasketMapper()
{
//ValueType property is simple
Property(b => b.SomeProperty);
//Complex type needs all properties mapped
Property(b => b.Address.Street);
Property(b => b.Address.City);
Property(b => b.Address.CountryCode);
}
}
}
我希望我的Address
财产保持私有,但我不能使用,Property(b=>b.Address)
因为不支持类。
是否有一种简单的方法可以告诉 EF 将我的Address
属性映射为复杂类型,就像它是公共属性一样?
我要避免的是必须将地址的所有属性添加到我的BasketMapper
.