DDiVita
DDiVita

Reputation: 4265

Need advice on model design using Entity Framework 4.1 Code First and base types

I need some advice on part of my model I am designing. As you can see in my Rfi entity, I have a collection of BaseImpact types. There will be several types of impacts that can be added to that collection. Each impact type has its own properties. As an example I created a Cost Impact and a Schedule Impact. Now, these are not very different, but you get the idea. I am trying to figure out how I can use this same type of model and then add the mappings / relationships to the database. I'd really like the BaseImpact to be abstract, but I may need it to be in the DB, but I am not usre.

    public class Rfi
        {
            public ICollection<BaseImpact> Impacts { get; set; }
        }

        public class BaseImpact : BaseEntity
        {
            #region Navigation
            public virtual ICollection<Comment> Comments { get; set; }
            #endregion
        }

        public class CostImapct: BaseImpact
        {
            public decimal Cost { get; set; }

        }
        public class ScheduleImpact: BaseImpact
        {
            public int days { get; set; }

        }

Upvotes: 0

Views: 62

Answers (1)

jlew
jlew

Reputation: 10591

See this series of posts on different options for modeling inheritance hierarchies in EF Code First.

Upvotes: 1

Related Questions