【发布时间】:2015-08-21 08:19:18
【问题描述】:
我的课程 Product 有 20 多个属性。我只想将Picture 映射到另一个表,让其他人映射到表Product。
class Product
{
public int Id {get; set;}
public byte[] Picture {get; set;}
...
...
}
我知道的唯一方法是通过ModelBuilder:
modelBuilder.Entity<Product>()
.Map(m =>
{
m.Property(p => p.Picture);
m.ToTable("ProductPic");
})
.Map(m =>
{
// All other properties here:
m.Property(p => p.Id);
m.ToTable("Product");
// But there are too many!!!
});
如上所示,映射所有其他属性很繁琐。有没有什么办法可以排除一个属性走不同的路而让其他的遵循默认?
【问题讨论】:
标签: c# entity-framework ef-code-first mapping