Entity framework separating entities for product and customer specific implementation

Posted by Codecat on Programmers See other posts from Programmers or by Codecat
Published on 2013-11-12T08:10:54Z Indexed on 2013/11/12 10:20 UTC
Read the original article Hit count: 228

Filed under:
|
|

I am designing an application with intention into making it a product line. I would like to extend the functionality across all layers and first struggle is with domain models.
For example, core functionality would have entity named Invoice with few standard fields and then customer requirements will add some new fields to it, but I don't want to add to core Invoice class.

For every customer I could use customer specific DbContext and injected correct context with dependency injection.
Also every customer will get they own deployment

public class Product.Domain.Invoice 
{
    public int InvoiceId { get; set; }
    // Other fields
}

How to approach this problem?

Solution 1 does not work since Entity Framework does not allow same simple name classes.

public class CustomerA.Domain.Invoice : Product.Domain.Invoice
{
    public User ReviewedBy { get; set; }
    public DateTime? ReviewedOn { get; set; }
}

Solution 2

Create separate table and link it to core domain table. Reusing services and controllers could be harder.

public class CustomerA.Domain.CustomerAInvoice 
{
    public Product.Domain.Invoice Invoice { get; set; }

    public User ReviewedBy { get; set; }
    public DateTime? ReviewedOn { get; set; }
}

© Programmers or respective owner

Related posts about c#

Related posts about architecture