Do I delete the referenced entity properties in an Entity Framework Code First Model, if I plan on using them with a Repository Pattern

I used the Visual Studio Entity Framework PowerTools to Reverse Engineer Code First model objects for an existing database. I ended up with something like this:

namespace PoolVAEFModel.Models
{
    public class Pool
    {
        public Pool()
        {
            this.PoolWaterMetrics = new List<PoolWaterMetric>();
            this.PoolWaterQualities = new List<PoolWaterQuality>();
        }

        public int Id { get; set; }
        public string Symbol { get; set; }
        public int WaterCapacityMax { get; set; }
        public int WaterCapacityMin { get; set; }
        public int WaterCapacityRegular { get; set; }
        public string WallMaterial { get; set; }
        public bool IsAboveGroundPool { get; set; }
        public string ContactPhone { get; set; }
        public string ContactEmail { get; set; }
        public string SanitationMethod { get; set; }
        public string LocationAddress { get; set; }
        public bool HasHotTop { get; set; }
        public bool JustHotTop { get; set; }
        public int WaterCapacityUnitId { get; set; }
        public double WaterDepthMax { get; set; }
        public double WaterDepthMin { get; set; }
        public int WaterDepthUnitId { get; set; }
        public virtual Unit Unit { get; set; }
        public virtual Unit Unit1 { get; set; }
        public virtual ICollection<PoolWaterMetric> PoolWaterMetrics { get; set; }
        public virtual ICollection<PoolWaterQuality> PoolWaterQualities { get; set; }
    }
}

I would like to use the Repository Pattern to abstract the database layer and was wondering what to do with the referenced entities e.g.

    public virtual ICollection<PoolWaterMetric> PoolWaterMetrics { get; set; }
    public virtual ICollection<PoolWaterQuality> PoolWaterQualities { get; set; }

Do I just remove the from my class file and just keep the simple properties?

Answers


Code first power tools created those navigation collections because you have a mapped foreign key relationship between those tables in the database. If you're not going to use the navigation properties in your code, feel free to delete, it won't hurt anything.


Need Your Help

In OctoberCMS how do you find the hint path?

php laravel namespaces content-management-system octobercms

Mail::sendTo($to, 'OctoberCMS.PhotoElegance::mail.contactform', $params);

Creating versioning and oauth2 based authentication with my existing project on cakephp 2.0 to laravel 5

php rest laravel oauth cakephp-2.0

I am upgrading from Cakephp 2.0 to Laravel 5.1. I need to do versioning if some one can suggest whether it should be in URI or headers?