首页 > 解决方案 > 农场相关项目的数据模型结构

问题描述

我目前正在尝试找出一个数据模型,并在它变得相当复杂时苦苦挣扎。我到目前为止所得到的解释如下。我将在 ASP.NET CORE MVC 应用程序中实现这一点,以帮助远程管理收获。

数据模型如下: 农场可以有多个田地,每个田地可以种植多种作物。每个农场还可以有多个不同作物的收成,我需要能够存储有关该收成的总作物产量的信息,该收成特定于该农场。任何帮助将不胜感激!

谢谢!

尝试的数据模型 -

https://imgur.com/a/tgGIRNq

编辑 - 抱歉没有指定我想要的答案。实体如下:

我目前有 -


public class Farm : IEntityBase<int>
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public ICollection<Field> Fields { get; set; }
        public DateTime CreationTime { get; set; }
        public ICollection<Harvest> Harvests { get; set; }
        public Farm()
        {
            CreationTime = DateTime.Now;
        }
    }

public class Crop : IEntityBase<int>
    {
        public int Id { get; set; }
        public DateTime CreationTime { get; set; }
        public string CropName { get; set; }
        public Crop()
        {
            CreationTime = DateTime.Now;
        }
    }

public class Field : IEntityBase<int>
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int FieldId { get; set; }
        public DateTime CreationTime { get; set; }
        public int FieldSize { get; set; }
        public ICollection<Crop> Crops { get; set; }

        public Field()
        {
            CreationTime = DateTime.Now;
        }
    }

public class Harvest:IEntityBase<int>
    {
        public int Id { get; set; }
        public DateTime CreationTime { get; set; }
        public int FarmId { get; set; }
        public DateTime HarvestYear { get; set; }
        public Crop Crop { get; set; }
        public Harvest()
        {
            CreationTime = DateTime.Now;
            HarvestYear = DateTime.Now;
        }
    }

标签: asp.netasp.net-core-mvcdata-modelingdatamodel

解决方案


推荐阅读