'How to add entity referencing two other entities to database to database in ASP.NET CORE

please I have these entities to be sent to database

MatchingChildtoApplicant  
    { 
        [Key] 
        public int MatchId { get; set; }
        public int ChildId {get; set;}
        public Child  Children { get; set; } 
            
        public int ApplyId {get; set;}
        public ICollection<Application> Applications { get; set; }
            
        public string MatchingBy { get; set; }
     
    }

this is the post request to send to the database

    [HttpPost]
    public async Task<ActionResult<MatchingChildtoApplicant>> AddNewMatching( int applyid, int chd, [FromForm]MatchingChildtoApplicant matchingChildtoApplicant)
    {
         //getting the application to match
         var gettheapplicantion = await _unitOfWork.ApplicationRepository.GetApplicantByIdAsync(applyid);
          if(gettheapplicantion == null){
              return NotFound("The Application to match was not found");
         }
                                
        var appid = gettheapplicantion.ApplyId;
          

        //getting the child to match with applicant
         var childtomatch = await _unitOfWork.ChildRepository.GetChildByIdAsync(chd);
          if(childtomatch == null){
              return NotFound("The child to match was not found");
         }
         var childtoid = childtomatch.Cld;
     
           
        //getting the login user doing the matching
        var userdoingmatch = await _userManager.FindByEmailFromClaimsPrinciple(User);
        if (userdoingmatch == null)
        {
            return NotFound("The user doing the matching details is missing");
        }

        var nameofuser = userdoingmatch.DisplayName;

        //declaring new instance of MatchingChildtoApplicant
        var newmatching = new MatchingChildtoApplicant
        {
             ApplyId =  appid,
             ChildId = childtoid,
             MatchingBy = nameofuser,
            Comment = matchingChildtoApplicant.Comment,
            TheApplicationAcepted = matchingChildtoApplicant.TheApplicationAcepted,
            MatchedDate = matchingChildtoApplicant.MatchedDate,
        };
        

This is where I get the error sending to the database

       //  var result = await _context.MatchingChildtoApplicant.AddAsync(matchingChildtoApplicant);

        // var result = await _context.MatchingChildtoApplicant.AddAsync(matchingChildtoApplicant);
        //   gettheapplicantion.MatchingChildtoApplicants.Children.Add(matchingChildtoApplicant);
        await _context.SaveChangesAsync();
        
        return new MatchingChildtoApplicant
        {
                           
             ApplyId =  appid,
             ChildId = childtoid,
        
            MatchingBy = nameofuser,
            Comment = matchingChildtoApplicant.Comment,
            TheApplicationAcepted = matchingChildtoApplicant.TheApplicationAcepted,
            MatchedDate = matchingChildtoApplicant.MatchedDate,
        };

The error I get is this The type arguments for method 'ValueTransformerConfigurationExtensions.Add(List, Expression<Func<TValue, TValue>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. [API]



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source