开发者

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

开发者 https://www.devze.com 2023-03-08 00:25 出处:网络
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 collec

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开发者_如何学C 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; }

        }


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

0

精彩评论

暂无评论...
验证码 换一张
取 消