Entity framework 4 ctp5 poco、基表对象和域模型

Entity framework 4 ctp5 poco、基表对象和域模型,entity-framework-4,poco,entity-framework-ctp5,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 InvoiceBaseCo

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

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;}
}
公共类发票TBL
{
公共Guid发票ID{get;set;}
...
}
公共类发票行TBL
{
公共Guid发票ID{get;set;}
公共Guid InvoiceLineId{get;set;}
...
}
公共类InvoiceBaseContext:DbContext
{
DbSet发票{get;set;}
DbSet发票行{get;set;}
}
公共发票:InvoiceTbl
{
公共虚拟ICollection行{get;set;}
}
公共发票行:发票行TBL
{
公共发票头{get;set;}
}
公共InvoiceContext:DbContext
{
公共数据库集{get;set;}
公共数据库集发票行{get;set;}
}
我在这里的主要目的是重用具有附加导航属性的类,这样我就可以轻松地处理模型中包含所有必需对象的小模型


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

您能用NHibernate实现吗?您好,示例代码中有一些错误。InvoiceBaseContext有两个成员名称相同的数据库集。你能澄清一下吗?