none
EntityBase and EF Question RRS feed

  • Question

  • My question has two parts:

    1. Using DDD is it a 'best practice'/advisable (or just overhead) to create an EntityBase class (Layer Supertype Pattern) for identities:

    public abstract class EntityBase
        {
            private Guid id;

            public virtual Guid Id
            {
                get
                {
                    return this.id;
                }
                protected set
                {
                    this.id = value;
                }
            }
        }

    public class Customer : EntityBase
    {
       ...
    }

    2. In a previous posting I read in Entity Framework CTP 5 using an EntityBase class (as in the above construction) obviously wasn't supported. Has that been changed since EF 4.1?

    Thanks.
    Guy

    Thursday, April 14, 2011 4:08 PM

All replies

  • It sounds like you are wanting Table per Concrete class inheritance which is covered rather well here.

     

    http://weblogs.asp.net/manavi/archive/2011/01/03/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-3-table-per-concrete-type-tpc-and-choosing-strategy-guidelines.aspx

     


    Devlin Liles http://twitter.com/devlinliles http://www.devlinliles.com/ If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Thursday, April 14, 2011 9:36 PM