0

我使用 Visual Studio Entity Framework PowerTools 对现有数据库的 Code First 模型对象进行逆向工程。我最终得到了这样的结果:

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; }
    }
}

我想使用存储库模式来抽象数据库层,并且想知道如何处理引用的实体,例如

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

我只是从我的类文件中删除并保留简单的属性吗?

4

1 回答 1

0

Code first 电动工具创建了这些导航集合,因为您在数据库中的这些表之间具有映射的外键关系。如果您不打算在代码中使用导航属性,请随意删除,它不会造成任何伤害。

于 2012-08-02T20:15:42.993 回答