I am trying to use patch to update a record in OData but the table consists of multiple primary keys so it is giving error as "The number of primary key values passed must match number of primary key values defined on the entity. ASP.NET MVC Entity Framework"
Here is the sample code.
public async Task<IHttpActionResult> Patch(Delta<PreferenceFormat> patch)
{
Validate(patch.GetEntity());
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
PreferenceFormat PreferenceFormat = await db.PreferenceFormats.FindAsync(_userId);
if (PreferenceFormat == null)
{
return NotFound();
}
patch.Patch(PreferenceFormat);
try
{
await db.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!PreferenceFormatExists(_userId))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(PreferenceFormat);
}
I need to pass 4 primary key parameter here:
PreferenceFormat PreferenceFormat = await PreferenceFormats.FindAsync(_userId);
How can I achieve the same.