Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core ASPNET即时加载不';HashSet不能工作_Asp.net Core - Fatal编程技术网

Asp.net core ASPNET即时加载不';HashSet不能工作

Asp.net core ASPNET即时加载不';HashSet不能工作,asp.net-core,Asp.net Core,我正在从事一个采用数据库优先方法的项目 在上述项目中,我有Offer.OfferPlaces和OfferPlaces.Offer关系 第一个似乎不起作用,通过Include(x=>x.OfferPlaces)加载它会产生空集合,而加载Include(x=>x.Offer)工作正常并加载相关的要约 这是EFCore中的一个常见问题吗?我是否必须实现排序的解决方法,或者可能需要在DbContext的modelcreating上添加一些东西 以下是优惠型号: using Microsoft.Entit

我正在从事一个采用数据库优先方法的项目

在上述项目中,我有
Offer.OfferPlaces
OfferPlaces.Offer
关系

第一个似乎不起作用,通过
Include(x=>x.OfferPlaces)
加载它会产生空集合,而加载
Include(x=>x.Offer)
工作正常并加载相关的要约

这是EFCore中的一个常见问题吗?我是否必须实现排序的解决方法,或者可能需要在DbContext的modelcreating上添加一些东西

以下是
优惠
型号:

using Microsoft.EntityFrameworkCore.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;

namespace MarketplaceOffe.DAL.Model
{
    [Table("Offers")]
    public partial class Offer
    {
        public Offer()
        {
            OfferPlaces = new HashSet<OfferPlace>();
        }

        public long Id { get; set; }
        public long CompanyId { get; set; }

        public virtual ICollection<OfferPlace> OfferPlaces { get; set; }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace MarketplaceOffe.DAL.Model
{
    [Table("OfferPlaces")]
    public partial class OfferPlace
    {
        public long Id { get; set; }
        public long OfferId { get; set; }

        public virtual Offer Offer { get; set; }
    }
}

请分享您的模型中的一些代码。另外,请查看生成的迁移,看看发生了什么,以及类型是否正确映射到预期的表。@Knelis添加了代码-生成的迁移没有什么不寻常的地方,它们映射到了正确的表。@JCode您的代码显示,一个要约可以有零个或多个要约位置,您的查询是否会为所有报价返回一个空的OfferPlaces列表?@CraftedPod是的,即使在数据库中考虑过——我每个报价至少有2个位置。另外,正如我所说的-OfferPlace.Offer loads fine-意味着有非空OfferPlace的报价。@JCode如果您仍然需要帮助,我们可以在