ctp5 poco,基表对象和域模型

时间:2011-01-31 09:43:21

标签: entity-framework-4 poco entity-framework-ctp5

为了简化我的类/对象重用,我想知道我是否可以这样做。

public class InvoiceTbl
{
    public Guid InvoiceId {get; set;}
    ...
}

public class InvoiceLineTbl
{
    public Guid InvoiceId {get; set;}
    public Guid InvoiceLineId {get; set;}
    ...
}

public class InvoiceBaseContext: DbContext
{
    DbSet<InvoiceTbl> Invoices {get; set;}
    DbSet<InvoiceLineTbl> InvoiceLines {get; set;}
}

public Invoice : InvoiceTbl
{
    public virtual ICollection<InvoiceLine> Lines {get; set;}
}
public InvoiceLine: InvoiceLineTbl
{
    public Invoice Header {get; set;}
}

public InvoiceContext : DbContext
{
     public DbSet<Invoice> Invoices {get; set;}
     public DbSet<InvoiceLine> InvoiceLines {get; set;}
}

我的主要目的是重复使用具有其他导航属性的类,以便我可以轻松使用模型中包含所有必需对象的小模型。

我尝试实现这个,但它主要被解释为继承,它开始寻找Discriminator列等,所以我想知道这是否可能没有太多的解决方法。

0 个答案:

没有答案
相关问题